That song is a Bob Dylan classic, and while Boston Legal did have musical moments, they were more likely to use original songs or songs licensed from contemporary artists.
If you remember hearing a song that sounded similar, it may have been a parody or an original song with a similar melody.
Do you remember any other details about the episode or the song? If so, we might be able to pinpoint the actual song.