Actually, this is legal. The reason is that most employment relationships are "at will". This means that a company can set the conditions of work much as it sees fit, including prohibiting employees from discussing politics or an election. This is true provided that such a prohibition does not violate the term of an employment contract/union agreement or constitute some form of legally actionable discrimination (which it does not appear to). Some speech is protected in the workplace, for example if workers wanted to discuss the formation of a union or the like, but otherwise for the most part an employer can legally mandate what can or cannot be discussed in the workplace. Accordingly, a worker can either accept the restriction, not comply but risk termination, or quit.