Hi Matt,
I am mtf and I was not born here neither so this is how it works. If the State where you live allows you to have a driver license or state ID regardless your undocumented status then once you have it, go to the court and fill a petition to change your name first. Once you had changed your name then go to the DMV to change your gender, they will only change your gender with a letter of your therapists stating that you live as a male and that you have started the HRT.
And voilà! 🙂
I hope this works for you, I got it changed 3 years ago and it was such a relieve! Good luck