I had a similar problem with my last monitor (with a Windows PC.) It would randomly flicker vertical lines, and those lines would show a “ghost image” of something that was on screen when it started. I think it had to do with its variable refresh rate, as it often seemed to happen after gaming or tabbing from full screen to the desktop. But I could never find a reliable way to replicate the bug.
I could always temporarily fix it by running a “stuck pixel” video in full screen for 10-15 mins, like this: (seizure warning) https://youtu.be/-2eQhhMvi-U
It wasn’t really “stuck pixels” but it seemed to blast the problem away for some reason. Could’ve been coincidence though.
If it’s a variable refresh rate issue between the Mac and monitor, you could also try turning Adaptive Sync off if you don’t need it: https://support.apple.com/en-us/102144 And also disable it in your monitor’s onboard settings if you do turn it off or already have it off.
I went through a few different GPUs over the years with that same buggy monitor, including the GPU I have now. I since upgraded to a new monitor, and this one has not had any problems in the 6+ months of using.
So I’d hazard a guess that it’s the monitor. Try the pixel video if it happens again or messing with Adaptive Sync. If it doesn’t work, try other similar videos. Maybe it will help.