Victor Wooten teaches this concept a lot at camps, workshops, and in his books. I've done a number of exercises with him over the years that reinforces the idea, from playing only "wrong" notes to playing the chromatic scale over changes to trying to improvise when the other musicians are intentionally shifting away from whatever tone center you try to settle into.
Personally, after 20+ years of camps and workshops and experience with the concept, this is my approach:
Every note has a color, or vibe, including the ones that aren't within the key/mode you are playing. Playing them confidently helps, but really knowing what they add is the secret. For example, play that E major scale, then slam a big fat C (or C major triad). It produces a very specific kind of tension and color both coming out of and resolving to the E-major scale. So, yes, you can totally play C over E major and make it work, but playing it with intention sounds a lot better than tripping over your cable and stumbling into it.
The reason most people sound lousy when they play "wrong" notes is because they change their groove, feel, and rhythm in response to it. Everything, even their body language, shouts "oops I didn't want to do that" followed by "I regret doing that" As a result, that note feels and sounds lousy to the audience compared to all the other notes that were played with strength and confidence. So, a good exercise (back to lessons from Vic) is to practice your chromatic scale and get comfortable with every note. Then, play at speeds where you have no control and are going to hit "out" notes regardless of your intent. Blaze up and down the fretboard, or close your eyes, lay your hand in a random spot, and start soloing from there regardless of how the first note aligns with the key.
Once you put those two things together you learn to accept and build around everything you play, how to add more colors outside the key center, and how to maintain your composure even when you play something you didn't intend to. We could go over resolutions, substitutions, and a million other tricks to make "out" playing feel good, but I think those two are the big ones.