You do go to jail, usually just court house holding, for contempt of court.
That doesn't mean your due process rights disappear. You can challenge the warrant and the applicability of the All Writs Act all the way to SCOTUS. You can even still file a writ of Habeas Corpus.
You can even say that you forgot how to make the modifications. The onus is on the DOJ to prove you haven't. Awfully hard to prove what's in a man's head.
You could even argue that there's potential criminal liability (e.g. state wiretap laws) in your assistance, and invoke the Fifth Amendment. It's also awfully hard to prove that a man has definitively not committed a crime.
Best and most commonly, you can convince the judge that as a matter of conscience there is no amount of time in jail that will convince you to comply with the court's order. Thus holding you in custody serves no judicial purpose, and you are free to go.
This may be one where going to jail out of protest is necessary.
I say that as someone who faced felony charges that were wholly fabricated, and was offered deal after deal, but I told them I would never take any deal because it wasn't right. I've never forgotten the look I got in response on the prosecutor's face.
I've got a feeling, however, that the FBI has made a grave PR mistake here. People have such a personal connection to Apple. A huge portion of the powerful population holds considers their iPhones their most significant inanimate posession.
Holding the makers of these devices indefinitely in a jail cell, without trial, might finally connect the American populace to the fact that they have just witnessed the largest scandal since... probably post-Vietnam.
This is a moment that where history turns on the decisions of a few. And people have been known to sacrifice far more than time in U.S. prison for ideals far less worthy.
If the warrant is upheld, it will be a very individual decision whether to comply.
Resistance has power, even under far more hostile governments than ours.
I'd like to think I wouldn't. But truly I don't think anyone can really know that until it's real.
--------
If anybody from Apple happens to read this:
You are already naked. There is no reason not to follow your heart. - Jobs