This phrase is from Hamlet. I always though it meant something like “stabbed with your own sword” or maybe “lifted up on your own spear.” It DOES mean “injured by the device that you intended to use to injure others.” However, a petard is not a sword or spear, as I mistakenly thought, but rather a box filled with gunpowder that was used in siege warfare to blast down a door or make a hole in a wall.
To hoise means “to lift or raise”, which is what happens to a person who sets off his own explosive device by accident.
A modern-day example
A petard can also be a kind of firework.
I’m going to spare you any graphic images of fireworks injuriess. They’re really gruesome.