You are right. A court that believes you can be compelled to reveal your password will likely hold you in contempt of court for refusing to do so.
And, yes, life in prison is indeed a possible repercussion of a "contempt" judgement. Just ask H. Beatty Chadwick who was forced to spent 14 years in prison (for "civil contempt of court") because the court asked him to cough up $2.5 million that he did not have: https://en.wikipedia.org/wiki/H._Beatty_Chadwick