One way would be to bang your head into the wall and cause an injury serious enough that a doctor could testify that you have brain damage and therefore memory loss.
If I was innocent, and legitimately forgot my password, and faced an indefinite time locked away, I would probably actually consider that as an option. Now that act itself could be an act of contempt, but then again you could always use the excuse that someone else did it to you. Or you could pick a sufficiently damaging fight with another inmate or guard.