First off: Happy birthday to your son! 2 years old is a very interesting time for a child. By then, children have started to get a real grasp on the world surrounding them. They already interact with peers. In a few months your son is likely to start to become self-aware ("Bobby wants..." becomes "I want..."). Language and communication abilities are going to start to explode. This is a very interesting and intense phase, and can put serious strain on children living through it – and on their parents.
On top of this, your son will become an older brother. A younger sibling being born is often a very hard time for the older siblings, especially if there is only one older child. From being the whole family's center of attention and the sole target of care they step down to the second place. And they had no saying in this decision, they weren't asked, and there's nothing they can do about this dramatic change in their world. They can make the obvious connection ("this wailing thing came and immediately took away what used to be mine") and blame the newly born baby, and it's not rare for the older child to lash out in frustration at the newest family member.
Keeping the balance of attention right and preventing the older sibling(s) from feeling bad about the new sibling can be very hard for parents. That is worst immediately after the baby is born (when the newborn is totally helpless and the mother might not be able to do everything she used to), but many toddlers feel it already during pregnancy, when their parents think and care a lot about the yet-unborn, when their mother cannot play with them as she might used to, because this is physically too challenging for her or because she might feel sick or tired. Many children will revert to demanding the comforter they had already abandoned, start again to come to their parents' bed each night, and show similar habits that their parents thought they had long since left behind.
Keep this in mind when you think about your son's behavior. And keep in mind that he is only 2 years old, and just started to get a grasp on the world. You cannot reason with a 2 year old as you can with a 6 or 8 year old. A 2 year old will only have started to learn to not to demand immediate satisfaction of every need or to deliberately step back. He cannot imagine himself in someone else's place and look at the situation from that other person's POV (as this requires self-awareness, which is not quite there yet around the 2nd birthday).
Also I want to do this sooner and avoid him thinking he is thrown out of the room by the coming of the baby.
With this in mind: This might be a hard time to teach your child to be more autonomous. He might already feel the imminent dethronement, and this might make him more prone to demand more attention. When you keep fighting over this for another 8 weeks, it might just be close enough to the birth of the new child that he (unconsciously) makes a connection and blames it on the youngest family member. Maybe this just isn't the right time to do this at all? I know that, after two years with your first child, parents feel like they deserve a little bit of privacy and return-to-normal. But you will have a newborn next year anyway, which will tear down every bit of "normalcy" you have. Is the break of two or three months you might be able to gain until then really worth the hassle it takes? (I'm not telling you to not to do this, because I don't know. I am just asking the question. You as the parents will need to answer it.)
Has anyone been through something similar?
Yes, definitely. Getting your children to go to bed easily is on top of everybody's list of what parents want their children to learn. Basically, there's two ways people deal with it. Some parents just enforce it. They lock the room (or whatever it takes to force the child to stay in bed) and leave, and after a few days or weeks the child will have given up. Now, call me a weakling, but, TBH, I cringe at the idea of willfully abandoning or even locking away a toddler that is upset about the parents not being around. My philosophy always is that, if a child weeps, it's upset, in distress, in need of help. And it's my task as a parent to provide that help. If a child doesn't want to sleep alone, why would I force it to? After all, we also feel forlorn when we have to sleep alone.
So when we expected our second child, we extended our bed (from 160x200cm to 200x200cm), so that there was room for all four of us. Our oldest did have her own bed back then, next to ours, and she was proud to use it, but came into our bed every morning and sometimes during in the night. She was allowed to go to sleep in her own bed or in our bed. We never put any pressure on her to sleep in her bed, other than making her very proud to have her own bed and be big enough to sleep by herself. (This is easy to achieve: Praise her being old enough in front of friends, suggest she might show off her own bed to visitors...) And we required everybody who cam to visit us to see the newborn to bring a present for our older child (who could appreciate it), rather than for the newborn (who could only appreciate warmth, a teat, and a new diaper).
The result was that, when the baby came, our older child slept in our bed a lot, too. (Which was OK, because we had the space for this.) Also she was all over her new sibling, cherishing it, and trying to be "helpful". We allowed and encouraged this as much as possible even though it sometimes caused a temporary "disadvantage" for the newborn, because in the long run it prevented her from feeling jealous and resentful. After a few months, any anxiety about being pushed off the center of attention went away. She retired to her bed more and more. (But I remember the oldest ones coming into our beds in the morning even when they were much older. They loved it.)