Judges do not have freedom of speech. Judges have “codes of judicial conduct,” which severely restrain their freedom of speech while they are in court.
It’s not a violation of my free speech rights if my boss tells me I’m not allowed to greet every customer at my till with “Go fuck yourself.”
Free speech isn’t the right to say anything you want with consequences in all contexts.