Let say you play in a band, you have a tune ready, with intro, verses , refrains and maybe some kind of bridge part, maybe that bridge is a refrain sequence moving over back to verse part or opposite. Only thing missing is to create a guitar solo. I have a couple of approaches for this for which I try to follow, and I would at the same time introduce some terms of my own, like for instance passive and active approach solos. You will try to make your solos approach the accompaniment actively. Accompaniment meaning the tune's overall content, chord progressions, song melody and the different tune sequences mentioned above.
As a rule of thumb the solo should be a short summary of the expression or feeling the tune gives, so whether it's a ballad, similarly should the solo be, and vice versa if it's a little heavier song, dealing with maybe some frustration, aggression. At the same way as the lyrics and song melody, the solo sequence is supposed to tell more or less same story. In many cases actually the solo is harmonic variations of the song melody, especially if the soloing is going to be performed in the same melody sequence as the song, whether it's during the verse, refrain or bridge part.
1. Brainstorming session
Record the whole tune with song and everything but without any guitar solo, listen to it several times and try to build up a soloing sequence in your mind. Maybe try to make some sequences of harmonic variations of the song melody. At the same time try to follow the harmonies of the chord or riff accompaniment and the drum rhythm. Basically you can say many solos are made up by shorts sequences of melodic questions and a replies, and maybe some bridging parts in between sets of questions and replies. In that sense the solo becomes an composition within the composition of the whole tune. The dependency is the accompaniment and overall progression, meaning it should consist of the of scales harmonies matching the chord riff progressions and the overall timing.
2. Feedback first trial
Record the solo isolated or type it down for later remembering. Record the whole tune with the solo and listen again. Eventually get feedback from band mates or friends.
3. Experiment
Try to experiment more with the recording without solo, just with free improvisation, and remember to record everything, maybe there are some parts that sounds cool and you wanna use in addition or in extended variation to the first brainstorming session. Sometimes the first thing that comes to mind or first trial works, like the first intuition or stomach feeling in daily life.
4. Active and passive soloing
Sometimes the solo part will go into a separate solo part sequence or bridge theme. It's overall important in the creative process that this part is such that the original atmosphere of the song totally changes, unless it's a longer epic, in which the mood may change, but that's another story. The best solos within rock music in my mind use an active approach towards the accompaniment harmonies, meaning chasing the chord changes, or chord progressions in a proactive manner. Especially if the tones scale changes the guitar solo should change slightly before entering the changed scale accompaniment part, maybe half a beat or bar before. This is especially efficient if you have solo over 2 melody main sequences in different tone scales, maybe the solo bridge parts move into the verse part. Or solo starts in verse part moving into bridge or refrain part which follows another harmony or scale. As you know it's called playing lead guitar, try to think what's supposed to be interpreted by this term. Another efficient sound is if the drums are supporting the solo, and some other instruments also do additional fills in.
5. Climax part
A solo might have one or more several climax part depending on the story or mood you wanna tell the audience. Some solos start out strongly with rapid high tones played with strength, some start of more slowly for a later climax it all depends on what you wanna express combined with sometimes the length of the solo part. Try to build small themes played in high and lower tones. Usually climaxes use high tones, long lasting and screaming or very rapid, but not necessarily.
6. Instrument and genre depended solos
If you have listened quite some music you have sensed that solos are not only depended of the genre, whether it's rock, hard rock, blues and jazz, but different instruments tend to play different kinds of solos. Like if you listen to a keyboard, saxophone, trumpet or bass. Sometimes they seem to use different tone sequences and intervals, like blues funk jazz organ sometimes use a lot of rapid high chromatic changes. Trumpet or saxophone might use more slow tones with bigger intervals. Sometimes it might be good to experiment with playing a typical piano or sax solo on guitar.
I hope this has given some kind of valuable input to those interested. Another vital part is off course the choice of sound and effects, personally I'm fan of experimenting with harmonic overlapping delays. I wish you good experimenting with lead guitar and future guitar solos.