Some backstory on the related feature first: they patched the game to make it so that certain hats "fall off" (some stay on the newly created ragdoll's head) upon a player death.
As Valve does when updating TF2, they broke this purely cosmetic feature, then fixed it, then broke it again (this was around 2013.)
My experience: Having played TF2 since release, I've seen exactly what you are talking about as a hat flying across the map when a player is killed by an explosion/other high impact method. Much like in the video you posted, sometimes client-side or server-side lag/delay will cause the hat from a just killed player to fly out of the ground.
Ironically, a Steam Community post on this exact phenomenon even references being an Engie and seeing it often... Probably due to the opportunity to be more observant than most when playing as Engie! :P
The short of it: This "bug" is almost certainly lag related. It has not been (as far as I know) an officially documented glitch and due to it happening only due to lag, it probably never will.