I don't know if you were asking a rhetorical question, but my opinion is that if you were in court under those circumstances, it's likely you are going to jail. If the FBI finds out you talked, you will be jailed [as I presume that's the threat]; if the court finds out you lied, you will be jailed for perjury. Only if you perjure yourself but don't get caught will you escape.
While I suppose in practice this is true, I don't think the 5th amendment would technically apply. By mentioning the gag order you are not incriminating yourself but rather committing a crime.
The argument goes "whether or not you are under a gag order, you can plead the fifth without incriminating yourself, so this is not actually a lose-lose situation". In theory.