May I suggest that you begin with a very easy melody with just one voice or maybe a two voice piece with bass notes on open strings. Learn a couple of bars by heart and play the melody over and over again and try to change the melody slightly without losing the classical touch.
When I was a fifteen years old guitarist playing rock solos and classical guitar pieces I remember that I had a desire to be able to improvise on my guitar in a classical manner. Nowadays I have developed this skill and I love to improvise in the style of composers like Sor, Tarrega, Paganini or others or just trying to find myself somewhere among the notes. These special moments are a form of meditation that clears my mind and also helps me as a composer to stimulate my creative abilities.
The ultimate exercise is to use advanced classical guitar solos. If you think about it you will realize that classical guitar pieces are filled with wonderful licks, more or less complicated. These licks can be developed and added upon to give you material that will help you developing your improvisational skills. For example, take a two bar passage in a classical guitar piece that you like and practice it until you master it and then memorize it. Now you can play around with it and break it down, change it, analyze it and so on. If you want to improve as an improvisational guitarist and musician you can regard classical guitar pieces as collections of very musical licks just waiting to be used.
I hope you feel motivated to try these hints and reap the benefits from improvising the classical way. I described how I was affected by this type of guitar playing and I guess you might feel the same. Good luck!
There are many ways to develop this skill. You can start with major scales, experiment with easy chords, or easy classical guitar pieces. The most basic requisite is that you want to learn this art and with this desire you will find ways to practice improvisation in all your guitar playing. I will just mention using classical guitar pieces in this article.
The most important reason for learning classical guitar improvisation is that it's fun! If you learn classical guitar improvisation it will also help you memorizing sheet music, it will be easier for you to compose your own guitar pieces in a classical guitar style, you can make up your own techniqal exercices on the go and it will help you understand your guitar in a better way.
Guitar: How To Improvise The Classical Guitar Way