It's an all-volunteer force, except when it isn't. Don't like the regs? Then get lost. Nobody has the "right" to serve in the US military, only the opportunity. As such, your "rights" in the military are what the military says they are.
Failing to shave regularly and maintain a decent haircut is acceptable in certain field conditions, like when you have no razors, or when you're in some pansy branch

. Aside from that, you maintain proper grooming standards at all times. If this particular rabbi were in my squad, I'd.....well....I don't know, but it would it would be a very fitting punishment with a touch of irony that either fell within the bounds of hazing regs or left no traceable evidence.
While we're on the subject, I also think that women in uniform should be forced to shave, nay, get a bikini wax. For hygienic reasons only, of course.