If you’re on a tri bike or have aerobars, on a relatively gentle gradient and your speed is above 20kph, it’s worth staying tucked. However, below that speed, you’re better sitting up as the increased comfort, ability to breathe and power production will outweigh the aero gains.
When climbing seated, the most important thing is to keep your upper body as still and relaxed as possible. This gives you a stable pedalling platform and you won’t waste energy bobbing or swaying. The main cue for a relaxed upper body are your hands. Whether you’re on the hoods, tops or bullhorns, barely grip them, almost just rest your hands on them. You should have a slight forward lean and, as the gradient increases, drop your chest more towards your stem and move forward on your saddle. This will help you control your front wheel and keep the power down.
When you stand, again, stay relaxed. Stand tall, be strong through your trunk and keep your head up and looking forwards. Some side-to-side movement of the bike is inevitable but don’t exaggerate it and try to avoid pulling too hard on your bars.