Speaking out and applying a moral perspective in the public square is not "legislating religion", but rather legislating and imposing its opposite. It is disenfranchising a particular set of voices in a democracy.
"That wise Men have in all Ages thought Government necessary for the Good of Mankind; and, that wise Governments have always thought Religion necessary for the well ordering and well-being of Society, and accordingly have been ever careful to encourage and protect the Ministers of it, paying them the highest publick Honours, that their Doctrines might thereby meet with the greater Respect among the common People." --Benjamin Franklin