I am Sri Lankan male to female transgender person (but my travel document still lists me as male) and have a boyfriend from the United States. Can we get married in the USA on a visit visa or tourist visa?
The same-sex part of your situation is irrelevant in the US.
The issue for you will be, if the plan is you enter the US on a tourist visa, marry, then apply to change your visa status on the grounds you are married to an US citizen. If you do that, ICE will suspect you of visa fraud -- and they will likely be right.
If you want to come to the US to get married and then stay, apply for a fiancée visa.
If you want to come to the US to get married and then return to Sri Lanka, a tourist visa is fine, but your marriage will not be recognized under Sri Lankan law.