Some clues: It only happens when pedaling. It does not happen on my trainer. It only happens when I have weight on the bike (does not occur when spinning pedal on stand). Other relevant info:
There are times when the noise is more or less gone. During those times, if I slowly increase my power it will stay quiet. if I quickly put the hammer down it will come back. It will also come back if I take a hard turn. I haven’t tested it enough, it seems to be less noisy the tighter the thru axel.
For me, it has come down to either the cassette, something with the rear wheel in general, or the brakes (although there is no rubbing otherwise). I think this is because those are the only things that are different when I am on the trainer.
Has anyone had a similar noise and know what the fix is?
Those were my initial guesses as well. It does not make noise when back pedaling. It also does not make noise on the trainer when everything is the same except the rear wheel is taken off. My assumption (though I suppose it could be wrong) is that it was not the bottom bracket or cranks because the noise goes away on the trainer.
It sounds like something cyclic. You say it doesnt happen on the trainer, my first guess would be the rear hub if you are using a direct drive trainer. I think a bit like you surmise. But it could be something thats loaded just vertically on the trainer but outside there a bit of horizontal and vertical loading and that horizontal aspect is causing the noise. Check if your crank/chainrings/bb/pedals/seat rails/clamps have play. Noises are funny though it could be emanating from anywhere which is stressed differently outside. Good luck
In my case I took the my bike back to Specialized 2 times. Both times they went thru everything. Seat post to BB to lubing between spokes. Each time it went away for about 100 miles then returned. Even my local independent shop could not make the noise go away permanently. I even replaced the BB with a Kogel unit.
I ended up buying a new crank arm and chain ring set with the new factory power meter ( replacing the 4iiii). That worked. Expensive but I now have piece of mind.