I know that in the TOS era the idea from Gene was that humans would have had to outgrown the idea of religion to achieve the civilization of peace and enlightenment that he was pushing for in Star Trek. That seems to have shifted over the years. Honestly I'm conflicted on it, historically religions are kinda shitty and oppressive and that goes double for the Abrahamic ones. So the idea that religion has been abandoned in the future is a nice one because you know, it makes sense that in a better future people abandoned the tools of control and oppresion that have divided them for centuries. But its made for this era of people and people want to see themselves in things and especially do not want be told that their deeply held beliefs are something they need to outgrow to progress
I don't think it's just that. Like, it is also that, TNG made an attempt to idealize its characters and society according to a particular mold and every subsequent Trek show has made some attempt to draw its characters back toward something relatable to the present day. That's a real thing that's happened.
But in my own life as an internet atheist, I've had my feelings toward minority religions change quite a bit since around 2010 when the split started to happen between what would become what are now the pro-science secularists and the anti-SJWs. I feel like what I now recognize is that any restrictions placed on minority religions tend to be for the benefit of the religious establishment with its ties to nationalism etc., especially by enforcing cultural uniformity and removing symbols of difference from the mainstream, and I don't want to carry any water for those guys. The way to break down the oppressive control that religions have over people's lives is to fight theocracy and force people to engage with religious diversity.
So I do expect religion to become less important in people's lives over the long haul, and I certainly
want it to, but paradoxically, I think the best way to end up in a place where no one feels the need to wear religious symbols in the real 24th C. is by explicitly allowing them to do so in our fictional one (and our real 21st). And Starfleet is a pseudo-military with ranks and things and sometimes treated as 1:1 with real-world militaries in many aspects of the daily lives of Starfleet officers, but it's also an office serial like NCIS or whatever where the characters' entire lives have to happen at work so that we get to see them in the show, so a lot of the restrictions of real militaries where people to get to go home for months at a time between tours of duty don't make sense in Trek.
There's also the tangle of culture and religion, because religion is an invented category for a subset of culture that corresponds roughly to the parts of life nineteenth century Christians associated with the church. Like, we only ever talk about Klingon "tradition" rather than "religion", but everything attaches to mythic stories that many Klingons seem to believe, which kinda
sounds like they're all deeply engaged in religious practice all the time, while the Bajorans' whole thing is "religion" but it's based on legendary elaborations built up around real aliens that exist and interact with them, but it's "religion" because they say the word "faith" a lot....
The thing that makes it really easy for me in Star Trek though is that like in Ungnome's examples, it's cultural significance rather than the "religion" label that seems to make the difference. If everyone on your planet is given a trucker hat upon reaching age of majority and wears it for the rest of their lives, you can probably wear it while on duty too.