You do not need any formal musical training at all to play classic rock songs in a cover band. Most of the classic rock bassists whose lines you would be playing had little or no formal training. So, yes, you can absolutely learn to do this by "just playing songs"--that is how the vast majority of rock bassists, both famous and obscure, have actually done it. Just focus on getting the notes right, locking in with the drums, keeping consistent time, and reproducing the groove/feel of the music. If you have a decent ear and guitar experience, you will very quickly pick up common patterns, intuit note relationships, etc. so that you can throw in your own fills and variations, if you want.
Needless to say, if you want to be a more "complete musician" and play more complex forms of music, reading music and knowing theory are pretty much essential. But for playing in most rock/blues/pop cover bands, these things are not strictly necessary at all.
Needless to say, if you want to be a more "complete musician" and play more complex forms of music, reading music and knowing theory are pretty much essential. But for playing in most rock/blues/pop cover bands, these things are not strictly necessary at all.