When I was starting out to play ( I mean starting to take it seriously and put hours a day, every day ) most of my time was spent memorizing my diatonic harmonies, and learning which scales fell into each key— and how certain scales and modes fit with genres of styles. Eventually, I became comfortable playing various modes over their corresponding diatonic chords. Of course plenty of effort can be expended learning to improvise melodically to seamlessly play with changes in a tune, but it’s here that most students of guitar plateau… or at least, don’t know what new thing to try out next.
For some, playing outside of a key can be a fun trick to experiment with. If taken from a blues background, extra-diatomic melodies can add distinction to a solo in an already instrumentally heavy piece— or at the least, create some sonic dissonance between the lead melody and other melodic structures within a piece. Playing with commitment and strength is difficult for under experienced players when using traditional melodies, but has further importances when stepping outside of a key. I like using the phrase stepping, because it implies a graduated journey that’s slow and steady, and eventually can come back to the starting position. This philosophy works well with a simple I IV V blues progression— if the V chord is used for the out of key melodies, the opportunity for screwing up is minimal since you’d only have a measure to work with.
Typically in a progression, the Dominant chord/tonic is used to lead the ear towards the root of the key— in the key of E minor the Dominant chord would be a B Dominant 7 [B7]. This leading of the ear is why the V chord can appear last in a 12 Bar Blues progression. If we use a diminished scale to play outside of a key, in our E minor example we can replace the B7 with a Bdim [ 1 b3 b5 bb7 ]. Using the diminished scale over the V chord in a progression (keeping in mind to end with the root of the key) can be a fun technique to experiment with… and would definitely spice up your playing, making it stand out from some overused tropes in blues riffs.
About the diminished scale; there are two forms of it… one that starts with a semi-tone (half step), and one that starts with a whole tone. If you’re following along and practicing in E minor, supplementing the B7 with Bdim, the half-whole version of the scale works best; as it has a close overlap with the B7 (diatonic) chord itself.
When you want to try this out over other keys, there are some useful online scale libraries to use for reference here (click me), or by just searching for "half whole" or "whole half" diminished scale studies. Just remember to use the diminished scale based around the V chord.