Can the signer of an NDA be forced to testify under oath?

You are referring to “privilege”. There are various types of privilege where there are specific rules on how or if evidence can be collected, based on a particular relationship. i.e. attorney-client, clergy-penitent, doctor-patient and maybe a couple of others.

Typically a contract that violates the law is also considered invalid and unenforceable. i.e. you can’t sue your drug dealer because you wrote up a contract for him to deliver you illegal drugs and he decided to stiff you.

There are regulations about government agencies collecting confidential information from businesses (generally, requiring the agencies to not show it to the public; though they can still use it as evidence if necessary). Note that the businesses still have to provide the information.
These regulations are completely different from the various privileges discussed here. They also apply whether or not there’s any kind of NDA in place between the business, current employees, former employees or other third parties.

So, I don’t think it’s accurate to say that the NDA has any impact; confidential information (under the regulations) is confidential regardless.

I’m sure there are other applicable laws/regulations that could apply to testimony and the possibility of a court keeping it secret; but I really highly doubt any of them depend on an NDA.

A government official seeking testimony isn’t the court. He is just another Joe doing his job. He can ask the court to keep the testimony confidential, but the court is under no particular obligation to do so just because he is from the government.

I’m also not a lawyer, but I’m pretty sure you’re thinking about this wrong.

If the legal agreement is to never do X, and there’s a specific case where you’re required to do X by law, then it just means that that agreement doesn’t cover that one specific case. It doesn’t mean you can also ignore the agreement to not do X in other cases.

By analogy: let’s say you lease an apartment to someone, and the lease says that they can’t have a dog.

At some point you find out they have a dog, and point out they’re in violation of the lease. They point out that they’re blind, that it’s a seeing-eye dog, and the ADA protects their right to keep it.

That doesn’t mean that some other tenant without a legitimate need to have a service animal could keep a dog as a pet. It doesn’t invalidate the entire “no pets” part of the agreement. It just invalidates the specific case where the law says otherwise.

The NDA I signed had a notification clause in it, and the penalties for not complying with it were almost as severe as the penalties for me blabbing.

That is correct, and this is the main reason why violence is the only currency that really matters in the illegal drug trade.

A contract cannot bind you to violate the law. So if the law requires you to testify then the contract is void to the extent that it purports to prevent you from testifying.