If you have any poop in your bowels and intestines and you have pee in your bladder before you die then yes you will have a bowel movement and poop your pants after you die and not before you die.
When you die you bowel muscles and bladder muscles relax and then you poop after death and pee as well which is what most people in morgues have experienced when they deal with dead bodies.
They usually have to clean up poop and pee from dead bodies which can be unpleasant so if you want to work in a morgue or doing autopsies then you need to be prepared to deal with cleaning a dead bodies poopy bottom as well as pee.
It has got to be worse than cleaning up a babies pee and poop when changing their diapers.
I thought about working in a morgue but after hearing about some people having to clean up poop and pee from a dead body I decided against it.