Put them in jail until they do or charge them with whatever the local flavor for "obstruction" is. In places where they're allowed by law to require you to give up a password not doing so when the proper steps are taken would usually be it's own crime, usually phrased as some sort of "obstruction" charge with it's own sentence. And that's just places where the law and citizen rights are a meaningful concept in restraining state power.
Depending on the country and the willingness to comply with legal norms somewhere between putting you in prison until you give it up and hitting you with a stick until you give it up.
And to be clear, in other words, that means you can’t be compelled. You can effectively resist giving up your password, you cannot effectively resist giving up your finger, gruesome though the prospect might be.