The People's Convoy egged in Oakland, CA as they protest by Buffy Wicks neighborhood
California Vehicle Code 23100 asserts
(a) Any person who throws any substance at a vehicle or any occupant thereof on a highway is guilty of a misdemeanor.
(b) Any person who with intent to do great bodily injury maliciously and willfully throws or projects any rock, brick, bottle, metal or other missile, or projects any other substance capable of doing serious bodily harm at such vehicle or occupant thereof is guilty of a felony and upon conviction shall be punished by imprisonment in the state prison.
So at the minimum this is a misdemeanor offense. It could be a felony if the accused is found to have intended to do great bodily injury, and that an egg (or whatever else they threw) was capable of it. The basic rationale for the law is that any such act creates a distraction to drivers at the minimum, which creates danger (if someone is surprised by the impact they may suddenly swerve and collide with other vehicles or property; their vision may be obscured and can no longer drive as safely as they should; etc.).
And this is just for the literal offense of "throwing something at a vehicle (on a highway = public road)". The act may create other offenses, such as violating littering statutes and creating a hazard. And if the act does result in grave bodily harm or damages, even if they did not intend it, the offender can expect to be held to account and liable for that as well. If anyone dies, they'll be on the line for some form of murder/manslaughter charges, for example.