What I often do is play one of my favorite songs that maybe isn’t as heavy on lead guitar parts, such as songs from Linkin Park or even blink-182, and I’ll play along with the song and write my own solos/riffs with the song as it goes along, incorporating different techniques I’ve learned that I think would best fit the song. Playing over backing tracks as previously suggested also helps. Don’t worry if what you write sounds like crap to you at first, artists almost never publish their very first iteration of anything. Many pieces of music go through tens of different iterations and versions before finally coming to what you hear on a track. So get out there, write some things based on what you’ve learned, and most importantly: have fun with it!