People who object to trans people being in fantasy are wild. As though some silly-hatted alchemist wouldn't simply invent Almazar's Gender Fluid in an afternoon and distribute it to every dungeon chest in the land. It's Common on the loot table and half the goblins drop it. You can brew it yourself with three mushrooms and eight snail shells. It sells for 1 copper at the merchant because the supply is so abundant. You fool. You melon. You absolute buffoon. The limits of what you are willing to imagine are an epitaph you wrote for your own freedom.
There is (or was, I don't think it exists in the current edition) a "cursed" belt that changes your gender in official D&D products. My personal headcannon is that it was developed by trans wizards, and deemed "cursed" by ignorant cis people.