Capacity, per a NEJM article that I don't have the citation here, implies the following:
1. Must be able to communicate
2. Must understand risk and benefits of a procedure
3. Must Appreciate Risks and Benefits
4. Decision made by patient (assuming 1-3 are met), is consistent with patient's values and understanding 2 and 3.
A patient who is too depressed or psychotic to really understand the concept of ECT or even communicate his/her preference, lacks capacity. This type of person in some jurisdictions might be a candidate for ECT assuming next of kin/judge are making this decision with the assistance of a physican. If someone is so sick he or she cannot eat, is self-mutalating, out of control, etc. and the benefits of a higher risk procedures outweight the risks, he could be eligible for ECT without the patient actually consenting.
Its a similar concept to having a demented/delirious patient with a gangranous leg. The patient is not in always in the right state of mind to understand that an amputation could be lifesaving and refuses this procedure. If the patient understands that amputation is the only option and disagrees, but is in the right state of mind and justify why, then she has capacity to refuse the surgery. I was going to use the example of someone with increased intracranial pressure leading to a need for a CSF shunt, but in this situation implied consent would probably kick in, but based on the above conversations, this would be "involuntarily" drilling a hole in someone's head according to pre-med.