In the US, every university is different, though some State systems have several universities that follow the same rules.
In general however, your gender is self defined. You are what you say you are, though some people will want to argue with you about it. Gender is a very complex phenomenon, and none of the aspects of it are purely binary. There is your "plumbing", which has more than two forms. There is your brain, which determines how you think of yourself. There is your hormonal system, which has something to do with how you feel. None of these are binary and for some people they are in conflict with one another. Trying to give a formal definition is a fool's game, though some try to play it.
You are what you think you are. Universities are more likely than not to respect that, with some exceptions for religious colleges. It isn't so simple/nice for pre-college education which can be overly influenced by conservative political/religious factors.
The news in the past couple of days has indicated that the current administration might try to "define-away" transsexual people by defining your "sex" as your plumbing at birth. But, funny thing, that isn't binary, and some people are born with intersex (mixed) genitals. Humans are complex. Trying to define us to be simple, is, again, a fool's game.