Before you spend the $$$, just unplug the harness from the hood switch, like TeaRex said. The connection will then be "open", and is the same as what happens when the switch is being held down by the closed hood. This completely takes out any variables and removes the hood switch from the equation. If you have no more issues with the hood switch disconnected, then that is for sure your problem. If the problem continues, then it is something else.
If the hood switch is your problem, there may be another thing causing it, other than a bad switch. The cabin filter housing front mounting point is height-adjustable. If it is mounted too low, the hood may not be pressing enough on the switch, and will cause an intermittent problem. Once you look at it, it will make sense. There is a pin with slits cut into it. The cabin filter housing has a clip that catches in the slits.
My car had the same alarm problem, until I disconnected my hood switch. Then I remembered that the last thing I did before I had the alarm problem was bleed the brakes, which means I messed with the left cabin filter housing. Resetting the height to where it originally was fixed that.