So this is a big one. This happens only when you have body mind awareness and have practiced yoga for atleast a few years.
You know exactly how to shift the pressure so that the injured muscle doesn't get aggravated. Just because you have shoulder pain doenst mean you should not work out or stretch and strengthen your other muscles.
Till then just keep practicing with a teacher and let them guide you on how to modify the asana to accommodate your injury.