If you don't want your meal to hit the highway, you need to put it in a secure spot. You can always tie your foil package to the engine. But placing it in a snug location in the first place will keep it from shifting around, becoming lodged in the engine or falling to the road below.
Experienced car engine cookers recommend a process called the foil test or foil cone test to help you place your meal. To complete this test, take a large piece of aluminum foil and form a ball or a cone around 8 inches (20 centimeters) high. Place it on the engine where you plan to put the meal and shut your car's hood. Open the hood up and see how much of the foil has been crushed. If the hood didn't touch the foil at all, your food package needs to be thicker than the cone to prevent it from sliding around. You can add more foil layers to your package or make some balls with aluminum foil to fill the space between the top of your package and the inside of the car's hood. If the foil was barely crushed, then your package should be about that thick. The pressure of the hood pressing down on the package will help to keep it in place. If your foil is severely crushed when you open the hood, your package needs to be thinner than the foil, or your meal will look like the crumpled foil.
Even if you're sure your food package is snug, you may want to secure it with a piece of wire. Use common sense when doing this. Use a lightweight wire and never secure the wire to a part of the engine that moves. Once you're confident the package will stay put, hit the road.