Emulate the effect of a lock-in amplifier on a signal with a programming script
A lock-in amplifier is used to extract an extremely narrowband signal from a noisy channel.

The tiny glitch you're looking for is not narrowband. Instead of a lock-in amplifier, what you need is called an "analog signal averager". One of the best descriptions of this can be found in The Art of Electronics by Horowitz and Hill.

The basic principle is to sample the signal into a large number of "bins", synchronously with its period. After a sufficient number of periods have been averaged, the uncorrelated noise is reduced, and you're left with the original waveform, including all of its harmonics (the glitch).