HI, Kylee, and welcome to the forum!
I sincerely hope you're asking this question out of curiousity, not because you're currently riding a rearer!
I believe this method is an urban legend, or in your case "grandpa lore."
There's a variation of smashing a water balloon instead, with the same principle of making the horse think it's smashed it's head and is bleeding.
I can't imagine getting on a horse with something as fragile as an egg or a water balloon, waiting until the horse reared, and then having the balance and agility to smash it and break it between the horse's ears at exactly the right time at the top of the rear.
In theory, I think the method would work. If you caught the horse at the top of the rear, and he believed he has smacked his head himself, I think that would provide some disincentive to rear again. In reality, I think it would be incredibly difficult to execute successfully.
If you are actually dealing with a horse that rears, I would 1.) get some professional help and 2.) spend my time and energy figuring out the underlying issues that caused the rear.