Since you didn't tell us where you were,    nobody can really say.
However,   it's likely that you'd have to speak with an attorney locally.     It's one thing getting a name changed,   but a gender mistake (and really - didn't someone notice this earlier?!)  is another thing entirely.