Holding your breath may not be a useful strategy against poison
@NathanS's answer covers the suffocation rules that seem very applicable to this situation, but I wanted to cover whether holding your breath is an effective strategy.
Your example of the golem
In your question, you state:
party is fighting against some creature with poison immunity, like golem
Looking at the golems with poison breath, that suggests you are discussing the Iron Golem.
O Iron Golem's Poison Breath (ênfase minha):
The golem exhales poisonous gas in a 15-foot cone. Each creature in that area must make a DC 19 Constitution saving throw, taking 45 (10d8) poison damage on a failed save, or half as much damage on a successful one.
The effect works on each creature in the area. It doesn't say that it targets each creature breathing, but just each creature. A DM can always rule how they'd like, but RAW, the effect works against any creature. Poison gas doesn't necessarily have to be inhaled in order to work - it can absolutely enter through other means.
Poison/gas effects in general
If the effect doesn't specify "creatures that can breath", then generally it works whether breathing or not.
As I said before, if a DM wants to rule that you need to breathe in order to be affected, that's totally fine.
Most importantly, the Basic Rules covers the different types of veneno and notes that holding your breath against the inhaled variety is not effective:
Inhaled. These poisons are powders or gases that take effect when inhaled. Blowing the powder or releasing the gas subjects creatures in a 5-foot cube to its effect. The resulting cloud dissipates immediately afterward. Holding one's breath is ineffective against inhaled poisons, as they affect nasal membranes, tear ducts, and other parts of the body.
The other poison types are contact, ingested, and injury - none of which would holding your breath be an effective way to avoid their effects.
The curious case of cloudkill
It does get a little squirrely with things like cloudkill quais Estados:
When a creature enters the spell's area for the first time on a turn or starts its turn there, that creature must make a Constitution saving throw. The creature takes 5d8 poison damage on a failed save, or half as much damage on a successful one. Creatures are affected even if they hold their breath or don't need to breathe.
This line suggests that other things may allow you to hold your breath and I'm really not sure why they needed to state that. Given that, it is absolutely plausible for a DM to rule in other cases that you can hold your breath.