I would think an employer has the right to set a dress code for employees, especially those who deal with the public. It could be as general as “no overt display of religious or political symbolism” or as specific as “black shirts, pants, and footwear.” Why not? A person is being hired to do a certain thing, fulfill a certain function, and that could include wearing a uniform, wearing a lab coat, wearing a face mask, wearing a hard hat, not wearing tennis shoes, not wearing shorts, etc.
An employee who accepts a job agrees to follow the employer’s policies, whether they pertain to punctuality, conduct with respect to the public, use of alcohol, use of obscene language, or any other thing. If an employee is aware of those polices and violates them, and they are understood to be grounds for dismissal, then yes.
I don’t see how an employer can be taken to task for stating and following its own policy.
The question of whether they should have a particular policy is an entirely different issue.