PhD student with mental health issues and bad performance
Be forthright with the student about what they are facing. Explain the various contingencies. They may be unaware or ill-informed. You could ask them which path they would prefer you to take... True, they may not be the best judges of their own best interests, or may not be able to act, but you can ask.

In particular, probably you indeed should not share information that you'd promised to keep confidential, short of issues like potential self-harm or harm-to-others. At the same time, it may be that your university has fairly strong guidelines about your supposed responsibilities in a situation like this. At least try to read up on them... whether or not you think it is humane or wise to comply. I suggest that you keep in mind that the university will be "covering itself" legally, first of all, with concern for students and faculty somewhat subordinate... so it is non-trivial to see what the truly best action will be.

In any case, I think it would be good to avoid allowing a disastrous thesis defense to occur, especially if there is no room for a second attempt (as at my own university). Being late but doing ok is vastly preferable to being on time and catastrophically failing...

No, I do not mean to suggest that laying this out for the student will magically transform them... but that it is fair to inform them of consequences of this and that, and ask them what route they'd want you to take.

And, by the way, is "removal from the program" merely (!?!) loss of funding? In my university, it is possible to continue to register (after everything but thesis and defense are done) without cost... and, thus, without necessarily having financial support from the program.