There is a thread here of a US Navy FtM service member who got away with being "stealth" for several years, before being found out and cashiered. I don't know how you can expect to serve much less pull it off in any military service that does not permit it.
Beyond that, military service is not a great way of dealing with depression (in fact if you say that during your recruiting/induction, you will probably be rejected). Universally military life... sucks. For the most part. Sometimes it can be cool, but mostly its annoying and stressful, and its easy to get depressed, really depressed. And your have ready access to guns and other dangerous things... You might really want to reconsider, esp. as a transperson.