In the 1970’s and 1980’s there were several books the either had characters that did it or promoted it.
Why is there no cooking tray in my new car’s engine bay?
Is it dangerous? (It would be less physically dangerous if there was a specific spot for it.)
I imagine the majority of the current crop of motor vehicle owners are not quite smart enough to realize that the hood even opens to allow access to the engine bay… Nor what parts of it get hot. Or too hot. Or are safe to access, etc. And in our modern litigious society there is simply far too much that can go wrong with this to make it worthwhile for any manufacturer to include as a deliberate feature. Like, rodent infestation in engine bays is already an issue. Imagine adding (potentially forgotten and abandoned!) food to the mix.
Edit: Another wrinkle I thought of is a lack of consistent temperature control. Your engine is designed to move your car, not remain at a consistent temperature.
The utility is also rather limited when you have access to a microwave or a convenience store. Or even a convenience store with a microwave in it, as many do.
So yeah, you can do it to be clever if you like but it’s not cut out to be mainstream activity.