How can I prevent sewer gas coming from the drain of an infrequently used shower?
There's two solutions to this - a trap primer and baby oil.

A trap primer is a device that has a tube running from a fixture to a seldom-used drain. Whenever that fixture is run, a small amount of water is diverted to the trap to fill it. There are also standalone primers that run based on a timer and don't rely on a fixture.

Since oil floats on water, baby oil will coat the water in the trap and keep it from evaporating. Next time you notice the trap is low, top it up and add some baby oil.

Adding a trap primer will probably be disruptive and expensive - I'd go with the baby oil.

You can use any oil, but baby oil (or plain, unscented mineral oil) won't go rancid as a food oil (vegetable oil, canola oil, etc) eventually will. Plain unscented mineral oil is sold as a laxative in most pharmacies and some supermarkets.