Sing the melody and find it on the uke, note by note.
Sure, a knowledge of the fretboard and some scales are a big help, but scales arn't music by themselves.
Bingo.
There are two parts to being able to improvise a solo: First,
create. Your musical mind has to come up with something to play. Second,
translate. You have to be able to then make your instrument play that something. Link your ears to your fingers. These are two related, but separate, skills. You should develop both as much as you can.
Picking out the melody mostly trains you in the "translating" part, but does feed in some creative ideas along the way. And don't limit yourself to melodies. Pick out solos, background riffs, etc.
Learning scales and knowing what goes with what helps the translating part too--you're mostly learning a set of heuristics that help you narrow the number of notes that the thing in your head could possibly be.
Learning licks and patterns helps feed both the "creative" and "translative" parts. Your ear is learning little modular snippets that you can swap around and modify in your head, and of course you're also learning how to play them.
Just
listening to solos helps the creative part. Check out music from soloists you like (and even some you don't like--you can learn a lot from bad musicians!). Listen to guitarists. Pianists. Sax players. Anyone! Really concentrate and listen to what they're doing--don't just have it on in the background while you sort your laundry. Five minutes of attentive listening is worth ten minutes of practicing scales. (Maybe more!)
Try scatting a solo. You already have a well-developed "translate" mechanism running between your mind and your mouth. So soloing by singing is almost 100% exercising the "create" muscle. I don't care how many scales you know--if you can't sing a solo, you will probably won't be able to play a solo on the uke.
Finally, there's a lot to be said for just jumping in and jamming. Not only does this exercise both the "create" and "translate" sides of thing, but it helps you just
get used to doing it in front of people. It peels away the judging and self-consciousness that can throw a wet blanket on the whole operation. It's one thing to be able to play a great solo in your bedroom when no one is listening. But to be able to be free and open and confident enough to do the same thing in front of others is something most people have to practice.
JJ