I think it meant that the person was dying from a venereal disease,
but the yellow handkerchief was a way of remembering and reminding people not to lead a dissolute life,more than a warning to keep away,does not the song belong in the same family as The Streets Of Laredo?