This project was done in a maker group couple of years ago. It is resurrected to share it with the wider audience.
It contains an IR sensor, 2x LEDs and speaker connected to Arduino. When the sensor detects someone in proximity, Arduino will blink LEDs and turn on nasty audio sound.
It is good enough to startle the little ghosts who come to get candy, but not to scare them.
Link to hackster: https://www.hackster.io/team-fd/arduino-pumpkin-cb9e08