I would distinguish between a judge and a legislator.
In this instance, pretending it isn't so obvious on its face for a moment, I would allow the legislator to get up, make his/her speech.... "people may not name their children after religious figures."
Suppose it's a more ambiguous religious subject and context. Even in this case, I wouldn't ban the speech. But I would do it just as we do it now. Let the legislator say his piece, then see what impact that religious expression has on the law before the legislative body, if it gets passed and someone is impeded or harmed based on religious beliefs of others, the law gets overturned.
Other than just making speech police, I can't think of a good way to police a ban on religious speech by lawmakers.
A judge is there to uphold the law and the moment she made that ruling her fate was sealed and the decision to fire her was correct.