Illegal aliens cannot enlist but non-citizen can or used to could.
I had a college roommate was on an international music scholarship from Yugoslavia (Back when Yugoslavia was a communist county) He wanted to convert his student visa to a green card as he was about to graduate.
He’d been a conscript in the Yugoslavian army like every other young man there before entering college. He went to US Army recruiter at the university and asked if they could use someone who spoke Russian and could drive a T-62 tank. He is now a US citizen and lives in Colorado.
Things may have changed.
Legal resident aliens can and do serve in the US military.
Illegal aliens cannot.