Not if they don't find out. Also interesting article from an army rag about the double standards present with dismissing Spenser Rapone, who wrote on his cap for a photo shoot at the West Point officer school (and didn't receive any blow back until he publicly posted the picture, upon which it was simply an "other than honorable discharge") and allowing a violent neonazi perpetrator to stay in marines. Even the marine they interviewed says he's not a communist sympathizer but it's bullshit what happened and in his own words "communism isn't even a racist ideology, while neonazism is".https://taskandpurpose.com/analysis/neo-nazi-marine-commie-cadet/
I really believe that there is room for a communist to make inroads into the armed forces community, so long as you can stay on the down low when necessary. IMO Spenser should have waited until honorable discharge to post picture, however in his own words he had grown disillusioned with the military during deployment, and wanted an early release.
I have heard even in Nazi Germany, that there were whole regiments of the wehrmacht that were full of KPD supporters.