P. - I'm not an expert, just a mom with a 2 1/2 year old son that thinks he is "boss" (ha). Yelling is only going to make matters worse, make him feel even more frustrated and upset. Yelling also teaches our children that that is the acceptable way to resolve conflict and respnod to others. It's never a good choice, but we all do it sometime. We need to be the calm in the storm. When children are upset, they are feeling fear or frustration or even hurt - it is our responsibility to show them that it is okay and things will be just fine (even without the candy they want! ha). It is hard, but it is the healthiest way to respond.
I wouldn't worry so much about his "attitude". Children at this age respond completely from emotion - that is why they throw tantrums or get upset when they can't have something. They have no logic and no sense of reasoning. He may feel scared about the new baby coming. He may feel frustrated that his daddy isn't there a lot. Or this just may be his time to "push the limits" to see how far he can go. Setting boundaries and expectations is the only thing you can do. He won't be like this forever and if you show consistency in what you expect, show him that he is loved and valued, then this phase will end sooner than you think. He needs to know that this isn't the way to get the attention he needs. When my son stops crying, that is when I hold him and get him what he needs. He is beginning to see this.
Suggestion: get eye to eye with him and calmly tell him that he is not behaving well and if he wants something (or wants mommy to do something) then he needs to be nice and calm. Keep repeating and don't give in. Send him in time out or in his room, but do it calmly and remember to always hug and kiss him in the end!
hope this helps.