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
> On July 10, 2009, Chadwick was ordered released from prison by Delaware County Judge Joseph Cronin, who determined his continued incarceration had lost its coercive effect and would not result in him surrendering the money.
14 years is pretty crazy, but all-time records are usually extreme.