Religion is a major part of many peoples’ lives, even in the military. I don’t remember any time they made a big deal about it in the various Star Trek series, besides Deep Space 9 because religion was so important to the species on the planet below the station, but I do remember a scene in the original series where the captain performed a wedding in what looked like a chapel but could have been merely the messdecks with a podium moved there and decorated. Many of the small ships do that on Sundays for the various services, both chaplain-led and lay-led services the chaplain isn’t as qualified for. On any given Sunday away from homeport there can be a number of services ranging from Catholic to Protestant to Buddhist to anything with a big enough following on ship.
Many people don’t go to the services for various reasons, whether because they prefer their literature to the perspective of the chaplain or because there is no service for their religion. Those people find ways to worship on their own. There are also cultures where their very cultures could be considered a religion, such as the Vulcans who spend hours a day meditating to keep their emotions in check or the Klingons to whom honor is the most precious thing in the universe. True, they may not be traditional religion but those are examples of species that have strong obvious motivation. Just a thought on character development but having a place to worship, or at least a designated way a room can be altered to be fit for whatever religious ceremony is expected. The messdecks are the most versatile rooms on modern naval ships although the main deck is usually where huge ceremonies, such as change of commands, are held. In future times the cargo holds may be the easiest rooms to adapt.
One last thing to think about is that the chaplain is the official counselor on modern naval vessels. Although chaplains are ordained members of a church somewhere they are also trained in regular psychology. If a family member dies or someone is contemplating suicide they are immediately sent to the chaplain to talk it out so the service member can calm down enough to not endanger themselves or the crew members by destructive behavior until they can be gotten off ship to go to the funeral or get professional help. I know in Star Trek: Next Generation they had Troy as a professional therapist that could also do anything needed for official records and in Star Trek: Enterprise they said the cook was the unofficial ship therapist. Whether official or unofficial there is likely always someone on ship that everyone talks to for educated help. I don’t think any fully functional government would send a crew through space for long periods of time without a person at least partially trained to deal with the typical problems caused by long periods of time indoors around the same people and away from family.