That's --- uh --- complicated. On the one hand, Canon Law says that anyone who commits a mortal sin (meaning a deliberate, serious sin you knew full well was wrong) is automatically deposed from any church office. On the other hand, you can appeal an excommunication. Since the pope is basically the court of final appeal, there's no way you can convict him, finally, under canon law, and make it stick.
Since a pope can only be judged by another pope, I reckon that would mean:
- A past pope.That could only be B16 escaping his handlers, jumping spryly over a wall in the Vatican Gardens, and finding his voice
- The present pope. Pope Francis could see the light, repent his sin, convict himself of heresy, and depose himself. That has actually happened: Pp Marcellinus, regnal years 296-304.
- A future pope. This has historic precedent, too. I'd have to check my list, but I think this happened to Pp Liberius, whose heresy was opposed by St. Athanasius; Pp Zosimus (ally of the heretic Pelagian); Pp Vigilius; Pp Boniface VI.
Best bet is probably that Bergoglio's successor convicts him posthumously of heresy and nullifies all (or, selectively, many) of his official acts.
Better yet, perhaps, would be: Christ comes again.
No matter which way it goes, it is not going to be easy. I would argue it's going to ge a lot worse before it gets better. Faithfulness in the midst of the most subtle and perplexing warfare imaginable, is going to be very difficult. But absolutely necessary.
Let us pray.