you'd have to keep track of completed worlds in savedata, and then use something like
jukebox.lua to check and play the correct music.
you might be able to do it in vanilla as well but you'd have to override a decent chunk of the overworld music and then make several identical copies of the world selector each with different music playing, which would be quite unwieldy and limiting (for example, all the worlds would have to be completed in a set order). if you aren't familiar with how to use lua, a decent (but potentially slightly outdated) set of tutorials can be found
here (for the basics) and
here (for the rest).