Metal solos are rarely improvised, most of them are composed and played more or less verbatim in every performance. But improvisation is composing on the spot. So most of the required skills are similar.
I'll tell you my own approach for learning metal soloing. You can adapt them to your own needs.
If you leave more eclectic styles of Satriani, Vai etc. aside, metal soloing is mostly based on minor (both natural and harmonic, melodic minor is rarer), minor pentatonic and blues scales. Learn how to play these on all fret positions, at least for the most popular keys (Em, Am, Bm, Dm and F#m for metal according to my own observation). There are tons of material on the internet where you can find the fingering patterns. Or you can reinvent them from scratch, this can give you a deeper understanding of their nature.
Then try to analyze the solos you already know (and the ones that you will learn) by relating them to these scales. You will also encounter some chromatic approach notes that don't belong to the scale, especially flattened seconds and fifths (F and Bb in E minor for example). You don't need to think in terms of modes (phrygian or locrian) to understand most of them. In metal soloing, treating them as decorative color notes is enough most of the time.
Then try to relate this melodies to the background harmonies. Metal accompaniment mostly uses power chords but they usually imply a full triad. For example an F5 in an A minor context usually implies an F major chord. See how the soloist emphasizes the chord notes of the implied triad and uses other notes as bridges between them. Metal soloing rarely insists on tension notes that don't belong to the implied triad.
Then reinvent the solos or solo fragments you've learned; create variations on them. Take some ideas from your favorite guitarists and change them. Replace a few notes, hold some notes longer and some notes shorter, skip a few notes, transpose them to a different scale degree etc. Build your own lick repertoire and practice them with a band or a computer.
Later, when you want to go deeper, you can dive into chord/scale theories of jazz improvisation. They make a lot of sense in metal too. But, depending on sub-genre, they're not strictly necessary; there are tons of great metal guitarists who never leave the "minor scale with some added color notes" territory and they still sound awesome.
This is for the theoretical basis of metal soloing. But the real distinguishing characteristics are the technical ones. "Shredding" techniques like alternate picking, sweep picking, economy picking, string skipping, tapping, tremolo bar tricks, palm muting, false and natural harmonics etc. give its distinctive sound to metal soloing. Again, there are tons of material on them on the internet. Practice slowly and build control first, speed last. Use a metronome (or a backing track) to gain a sense of rhythm.