How do you improvise a countermelody? Listen to things in the music and respond: imitate, vary, fill in gaps. Which tracks, though? Start with music that is harmonically uncomplicated enough that you can predict where it's going, but with enough rhythmic interest to give you something to react to. I do not recommend the blues for this purpose. It's a popular strategy among well-meaning music educators, and I get why, but blues improvisation is not a beginner-level skill. So what should you use?
I like the first three and a half minutes of "God Make Me Funky" (or the shorter single version.) The tune is in E, and you can use Mixolydian, major pentatonic, minor pentatonic or any combination of the above. Try following and responding to the guitar.
In a similar vein, try "You're Gettin' A Little Too Smart" by the Detroit Emeralds. There are chord changes but they more decorative than functional. You can more or less just blow in E.
How about songs with more chords? You want your improvisation to accent the important chord tones.
"Seven" by Prince is mostly in A Mixolydian mode, alternating A and G. But there are also prominent E chords, which include G-sharp rather than the G-natural from A Mixolydian. You should have no trouble hearing the difference.
"Nobody Knows" by Pastor T.L. Barrett and the Youth for Christ Choir is a step more complicated. It's an open-ended loop of Cm, Eb, Ab, Fm and G7. All those chords come from C natural minor except G7, which includes the raised (natural) seventh characteristic of C harmonic minor. So make sure to raise B-flat to B-natural when the G7 chord comes around.
Leading tones are even more important to be able to hear and play in songs that use secondary dominants. The bridge of "Your Cheatin' Heart" by Hank Williams is a gentle introduction to the idea. The song is in C, and the chords in the verses are C, F and G. Sing or play C major all the way through and you will be fine. When you get to the bridge, however, there's a D chord on the line "you'll toss around". This chord is the V chord in the key of G, and it resolves to G on the line "and call my name". The active ingredient in the D chord is the note F-sharp, the leading tone in G. This note is outside the key of C, and your improvisation will sound more musical if you highlight it, along with its resolution to G on the next chord.
For greater funkiness, try improvising over the James Brown version of the tune. He does it in G, so the secondary dominant in the bridge is A7, and you want to accent the out-of-key leading tone, C-sharp. This is more of an improvisation challenge, because James Brown uses bluesier harmony and funkier rhythms, but maybe these elements will inspire you more.
For a more complex chord progression, try "I Wish I Knew How It Would Feel To Be Free", as recorded most famously by Nina Simone. Here's my chart. The tune is in Bb and you can mostly play Bb major or Bb blues over it, but there are several secondary dominants too. In the first bar, there's a D7 leading to G. In the seventh bar, there's a C7 leading to F. There are also a couple of bluesy E°7 chords. You can intentionally aim for the out-of-key notes in these chords, or see if you can find them by intuition.
For another gospel-flavored tune with nice secondary dominants, I like "Baby's In Black" from Brad Mehldau's beautiful Beatles album. He plays it much slower than the Beatles do. I suggest looping the section from 1:55-2:20. The tune is in A, and the bridge section chords are F#m7, B7, D, E7. Notice that the B7, the secondary dominant in E, doesn't resolve their right away; instead, the D-sharp in the chord resolves down to D.
Where to from here? Jazz standards like "Autumn Leaves" or "Blue Bossa", Grateful Dead modal jams, or the blues once you are well enculturated. I have an extensive collection of one-chord grooves, but beginners can find them daunting because there is less structure to hold onto. More conventional songs give you some improvisational footholds.