I think this is a common question! I used to think earthworms could do this, but they don’t 🙁
Caenorhabditis elegans (the little worm I work on) was always thought that it couldn’t do this, then some amazing people found it could! If there is a nasty bacteria that likes to eat the C. elegans, it infects their bottoms and makes their tails knot (this is so there is a bunch of juicy worms for the bacteria to eat!). Usually the worms can not escape so meet a nasty death, but occasionally, a young worm can cut itself in half and crawl away leaving the tail stuck in the knot. Kinda cool but a bit gross!