I would assume there are international agreements about what information is on a passport or other government ID, and that governments are accountable for the accuracy of the information.  Germany has passed a "3rd sex" law so that sex can be left blank for intersex babies on their birth certificates, reflecting the objective fact of their being intersex.  That might actually be a smart solution for transgender people who don't completely transition to the other sex.  Beyond that, I can't imagine government would allow anybody to write in "two-spirit" because it's not objective information, nor to write in male when they're female because it's not accurate.  And I can't see the courts ruling that government can't accurately identify sex on government ID either.  We may have added the concept of gender identity to our laws, but that doesn't mean it replaced the concept of sex, which also still exists in law.