Intentional use of this can be really effective and dramatic during a solo, if done right it can be pretty captivating - I think because there's so much tension and then resolve when you come back. I have a few examples off the top of my head below, there are tons of these we could talk about, maybe post some cool ones? Over the years I've incorporated my version of this into my playing, but don't tend to get it right all the time. What I do is basically play a motif in key, then repeat that a half step sharp or flat, then resolve back to being in key, but it's not always easy to have it come out as a single, solid phrase. If my timing isn't quite right it can just sound bad and unintentional, more like a mistake than anything else. Can someone who is well versed in this type of playing help me with some methodology I can work on, and maybe a few tricks that can help me make things sound more polished?
Herbie does a ton of it here, but the Scofield solo is amazing (I set time to start of guitar solo):
A guy I don't know (Dario Chiazzolino) playing with Greg Spero, just found this recently: