The short answer? No, while in the womb, a fetus doesn't poop – although it does pee.
However, some waste does accumulate in its lower intestine throughout the pregnancy, which is a result of nutrients received from the mother via the umbilical chord. Called meconium, the fetus does not poop this while in the womb.
The fetus will excrete this sticky, greenish waste shortly after birth. In rare cases, due to distress during pregnancy, the fetus will release its waste while still in utero – potentially resulting in meconium aspiration syndrome, which can be very dangerous for the baby if it inhales the mix of fluid and poop.
Take a look at MinuteEarth's video explaining more.