Is there a way to change AC 120 V @ 60 Hz to AC 120 V @ 40 Hz?
Here's an article on the subject with some build vs. buy ideas:

https://gammalighttherapy.com/blogs/gammalight/how-to-build-a-gamma-40-hz-led-dimmer

In short, you'll need a circuit that does two separate things:


Rectify the incoming 60 Hz AC to DC and then
Pulse the lights (I'm presuming LEDs will be needed to get the flashing that you will need) on and off using a DC switch at the desired frequency (40Hz) and duty cycle (the ratio of time that the lights are on and off).


Personally, I'd consider buying the AC-DC part (this will make the project safer, too) and then you can build or hack together a simpler DC LED modulator like the one that is shown in the article I linked to, above.

Here is the circuit from the article - it uses a 555 timer and that's a reasonable place to start if you were going to build your own circuit.



If you are up for a bit of programming, an Arduino or an Adafruit Feather board can do the PWM (Pulse Width Modulation) output that you will need to drive an LED light strip.

This isn't the same as modifying an existing light socket but it may be a safer and easier place to start.