Fit a reed switch, it uses a magnetic field. bonnet open breaks contact and could switch to live, and would not activate while driving unless you lose your bonnet.
you would need a normally closed one mind and a small magnet screwed,glued above where it sits.
something along these lines...