Depends. What type is it?
An electrolytic or tantalum bead capacitor will have markings on it that indicate its polarity. Reversing it will damage the cap and they can explode
A ceramic or film capacitor doesn’t have a polarity and can be installed either way.