1 spawn a piglin
2 let the piglin charge up his crossbow
3 kill the piglin while its charging up his crossbow
the crossbow loading up sound still plays while the hoglin is already killed.
A few versions ago, the bug also happened with creepers that are charging up, but I don't know if it is fixed already.
The bug might also happen to other mobs, but I didn't test it