Have you asked the Pediatrician about it?
have you talked 'with' your son about it?
Maybe just see what he says or thinks or feels about it... many times kids say things that we may never have thought of with our "adult logic."
He's 5 now... so I am assuming he is capable of expressing himself. Let him express anything- his fears, concerns, feelings, stresses, problems etc. and just listen without judgment or 'lecturing' as we Moms often fall into.
As you said, it started happening right prior to the birth of your 2nd child and hasn't stopped nor gotten better since then.
Maybe... it is something that just still affects him or stresses him out.
Some kids, feel actual "stress" when they "become" and older child. "Being" and older sibling...is not always easy shoes for a child to fulfill.... because they become MORE expected to 'be' older even if they are not ready etc.
"Regression" in a child (which your son is doing with his pooping), is a signal of some kind of 'stress' in a child.
Perhaps, he needs help to communicate whatever it is that bothers him or whatnot. Sometimes, "boys" don't know how to express themselves and they think they cannot have feelings and have to be 'tough' and 'manly' about it... or a 'big boy' so they don't say anything about their 'feelings.' But it is detrimental because boys need to learn how to express feelings. Or they get pent-up.
I would not do the punishment route. It will not work. And although it is 'embarrassing' for you, I am sure it is for him too... although kids, even if they ARE embarrassed they will 'act' as though it does not phase them.
I would talk with him about it... even perhaps asking him how "you" can help. Kids often have good ideas.
My daughter, when I had my 2nd child, went through bathroom accidents too. It was just that her "life" was not the same and a big change for her. So we provided more comforting/understanding for her. Then it stopped. She felt more "pressure" as a child having a "baby brother" around... she felt "responsible" somehow... which is too much pressure/burden for a child to carry on their little shoulders. Although I thought she understood, I had to tell her that MOMMY is responsible for her baby brother... not her. Even though she is just trying to be caring. She DOES NOT HAVE TO worry about things or him crying etc.
All the best,
Susan