The teacher is an idiot. Just teach and ignore the hat.
If the rule is no hats in school then enforce it and have him remove it and make no reference to what is on the hat. It’s a stupid rule but don’t make a rule unless you intend to enforce it.
I work in post-secondary education and I can assure you leftist are in total control of the classroom and indoctrinate at will. You have a choice, regergitate the leftist BS to them and pass or challenge their non-sense. You will be ridiculed, harassed and eventually told to shut up if you want to remain a student and you will fail if you do remain. There is no open expression of ideals and debate anymore.
If I were the students parents I would be all over this with the principal, teacher, superintendent and school board. How does this commissar get away with calling a student an Ahole in and during class? Teachers yammer and wail they want to be treated as “professionals” yet act like union thugs to anyone who dares question their love for the children.