I personally don't have a under hood light, (bummer) but I have seen two designs.
One design uses a mechanical switch (usually located in front of the engine bay) that the hood depresses when it's closed.
The other design uses a switch (like a mercury type) that will close/open (turn on/off) depending on the position (like a bubble level, of sorts.)
Not much to go on, but good luck.
Thanks,
David