It depends on the nature of the injury. Yoga can be particularly good for both prevention of and rehabilitation from injuries.
Be sure to let the teacher know about any injuries before the class begins. It may be useful to arrive early to discuss your issues with the teacher, who will suggest ways to modify the practice or work with the injury safely, or may suggest that the class is not suitable until the injury has healed.
Always consult your doctor first before attending any class whilst injured.
You could also book a Private Yoga Class where a teacher can help you adapt your yoga practice to accommodate your injury.