In some songs, the little riffs are imported from earlier versions. For example, in Aldrine's version of "Summer Breeze" the intro and recurring riff is (in one or another form) also in the original Seals & Crofts version and the Isley's one. In a case like that it's a matter of finding where those notes fall on the uke, and playing them in a way that sounds cool.
In other cases there may be simple touches such as hammering on certain notes when playing chords. That gives a nice little flourish and adds a bit of colour and interest.
When people invent their own little picking bits they are usually based either on the melody itself, or on related scales, or on the arpeggios (spread out chord notes) of the chords used in the song.
That doesn't necessarily mean that the player is aware that those notes are from such and such a scale or arp. Many, maybe most, make things up by ear.
Learning which scales go well with which chords is a bit of a can of worms and is something that takes a bit of work. Perhaps the easiest places to start are with Major and minor pentatonic scales, and chord arpeggios. Those give you a limited basic framework to get you started in making stuff up. With the scales, if you learn the patterns you can then shift them about so they fit in different keys. That's MUCH quicker than trying to learn the actual notes for each key.
Bear in mind that most of the little picked licks and riffs you hear are not improvised on the spur of the moment. 9 times out of 10 the player worked out the arrangement and has played it many times, so it looks easy for them.
A good way to start is to strum through the song chords and make up little licks by scat singing them or humming. when you come up with a bit you like, figure out the fingering on your uke.
I'd recommend recording while you do it. There are few things as annoying as working out a neat riff and then, next time you pick up your uke, realising that you can't remember how it goes!
If you decide to work on scales,
AcousticMonster's scale charts are a great resource for learning some moveable patterns.
.