so am i right in thinking that there is a bare cable running from the entrance to the exit of the toptube? if so, is there some sort of cable stop at the entrance and exit?
if so i think i would just remove the front cable stop throw some expanding foam in there. work the cable back and forth while it's setting. in essence creating a makeshift sheath around the cable to help prevent it from rattling against the toptube.
replacing a worn out cable could be tricky however. a coat hanger, i suppose, could be one solution, i guess.