It's a great question. The answer is PRACTICE. Simple to write but tricky to do in reality. I appear to be confident - and I am in general - but parts of it have taken practice, e.g. saying no at work and meaning it and following through. I still practise now.
In your example, rehearsing neutral responses which might help you feel more confident is potentially powerful, e.g. a quiet 'Sorry?' when a comment is made might give the speaker pause for thought.
Also putting yourself in slightly more uncomfortable situations progressively over time (weeks and months), and developing your responses and reactions, just like you'd practise riding a bike.
Trying out low risk responses, like firmly and briefly declining an event you don't wish to attend, and building up from there.
Often saying less: giving short responses and not excusing yourself for your own valid choice with lengthy reasons (you don't have to: it's your choice). It gives other more confident people more to work on to try to dissuade you.
Physical confidence is useful too, e.g. where you stand when discussing something.
You can do it
. Please PM if it might help.