When I joined the U.S. Army Reserves in 1999, there was a specific question on the enlistment forms about about whether I was joining due to an “or else” court judgement (I don’t remember the actual wording, but that was the gist). Answering “Yes” to that question was a bar to enlistment. I don’t think that’s changed since, and I believe it’s true for all branches. Now, as Loach points out, recruitment standards change all the time. There are waivers for just about everything. It wouldn’t surprise me if some Soldiers who answered “Yes” were waivered into the Army during the height of the recruitment crunch c. 2004-2008. As a general rule, though, if you’re being coerced into joining the military to “straighten you out”, the military doesn’t want you.
A couple of anecdotes:
When you enlist into the U.S. Army Reserves, you enlist into a specific slot in a specific unit. It’s standard procedure for the enlistee to attend the once-a-month weekend “Battle Assemblies” while waiting for a Basic Training slot to open up, which sometimes takes months. I remember one Soldier in particular who, prior to Basic, was an active detriment to the unit. Lazy, late for everything, borderline insubordinate, etc. There was a limit to what we could do with a pre-Basic Soldier, and we had a very limited time available to get everything done we needed to during the weekend, so we (NCOs) mostly just tried to put her somewhere where she wouldn’t do any damage. Admittedly, a bad approach both for her and for the unit, but she just seemed like she was more trouble than she was worth. After she returned from Basic, though, she changed dramatically. She still wasn’t really a model Soldier (she never really showed any individual initiative), but she followed orders, showed up on time, and performed her duties competently. I have no idea if that carried over into her civilian life, though. There’s a big difference between dealing with bosses that can, in theory, send to you to prison for back-talking, and dealing with bosses who can, at worst, fire you.
As a civilian, I got pulled over once for expired registration (I just plain forgot to renew it - completely my fault). In my county of residence, the standard procedure for expired tags was for the officer to issue a ticket with a court date. If you renewed before the court date, and showed up to court with a valid renewal, the court would nullify the ticket. Also, in my county, traffic violations and misdemeanors were put on the same court docket. So, while waiting for my turn to show my renewal, I saw a number of misdemeanors being processed. One was a sentencing (I don’t remember the exact charges, but it was something like disturbing the peace or disorderly conduct). Prior to the sentencing, the judge asked the defendant if he were still enlisting in the Marine Corps - it was obvious from the context that in his original bench trial, the defendant had told the judge he was planning to do so. The defendant replied that he had enlisted, and was awaiting a date to ship out to Basic. The judge handed down a very light sentence (I don’t remember the details, but it was something like a small number of hours of community service and a suspended jail sentence). Again from context, it was clear that he hadn’t been formally sentenced to enlist or face jail, but, wink, wink, nudge, nudge, because he enlisted, the judge handed down a very light sentence, and this was the implicit deal they had worked out at the trial.