Maybe someone asks them about their faith, in an informal setting, such as during lunch, and then they answer the question that was asked of them regarding how their faith applied to gay marriage.
If you then punished them for this, then that would absolutely be an example of illegal discrimination, on your part.
Again this is in no way unique to muslims, and is just as likely to be the case with similarly devout christians so I don't see why you need to focus on islam specifically. I've personally also worked with orthodox jews who I am sure hold a lot of opinions I disagree with and somehow they managed to never voice homophobic or misogynistic comments & I managed to never tell them what I think about interpretations of the bible as the literal word of god.
This is a situation which among reasonable people doesn't require outright ban of "political speech". You can cultivate a good company culture that deescalates flame wars without such a blunt instrument that may also have a lot of undesirable side effects.
It is very much possible, that according to the law, you are engaging in illegal discrimination against certain religions.
> I don't see why you need to focus on islam specifically
Well, the important reason why to focus on certain groups, is because of the possible illegality of your actions. Thats why.
If they say that as a reaction to a gay man posting somewhere "I'm out of office next week as John & I are getting married" than answering this with "with all due respect, as a Muslim I can't support you getting married to a man" is out of place. If they repeat after being called out that then yes that's a problem.
They have the very reasonable possibility of simply not saying anything but that may require developing a company culture where people learn if and when to do that - this may require some "political" discussion between consenting adults and that's fine!