I’ve done tediously lengthy lawsplainers on the First Amendment rights of public employees before, here and here. Those posts have the explanations and citations. This is the cheat sheet.
When the government is an employer, it’s wearing two hats: government-as-your-government and government-as-your-employer. The government-as-employer can punish employees for things it couldn’t punish them for acting as government-as-government. Which things? It’s complicated.