In Australia it varies a bit from state to state but you can change your gender on any document, passport, driving licence, medicare, ATO etc but not your birth certificate. If you do that (at least in SA) you cannot be in a same sex marriage.
Why? F knows!!
So I am now legally female ,married to a woman so I'm in a same sex marriage but with a male birth certificate and that means I'm not in a same sex marriage.
See it is obvious!