I am non-EU citizen and my girlfriend from Spain. I am Bangladesh national. Can we get married in the consulate of Spain in Bangladesh or have to try somewhere (neighboring countries) else?
The answer is MAYBE
According to Spanish Exterior Ministry the conditions for consular marriage are:
A consular marriage may only be held when at least one of the parties is Spanish and if the laws and regulations of the receiving state do not oppose consular marriages.
Since you're non-EU citizen the Spanish consulate will not perform the marriage unless Bangadesh recognizes consular marriage (for which I can't find confirmation).