Even within the United States, this would depend upon the jurisdiction involved. Some jurisdictions recognize a legal privilege of a journalist to keep confidential sources secret (also called a "reporter's privilege"), while others do not.
There is a split of authority on the question within the various circuits of the U.S. federal court system, and there is also a split of authority between different U.S. states.
The First, Second, Third, Fifth, Eighth, Ninth, Tenth, Eleventh, and
D.C. Circuits have all held that a qualified reporter's privilege
exists. In the recent case of U.S. v. Sterling, the Fourth expressly
denied a reporter's privilege exists. Furthermore, forty states and
the District of Columbia have enacted statutes called shield laws
protecting journalists' anonymous sources.
Three U.S. Court of Appeals circuits, the 6th, the 7th and the Federal Circuit, do not have any controlling case law on the subject. Ten U.S. states do not have shield laws protecting journalists' anonymous sources.
The U.S. Department of Justice, as a matter of policy, seeks to compel journalists to disclose their anonymous sources only under specified conditions where the need is great, but this policy is not a defense available to a journalist in a case brought by the U.S. government.
In the absence of a legal privilege, the journalist could be incarcerated until the information is disclosed or the need for the information is moot, for contempt of court. Quite a few journalists in the United States, faced with that choice, have opted to be incarcerated rather than to reveal a source.
If the subpoena is upheld, even if the face of a good faith effort of the journalist to quash the subpoena on the basis of a legal privilege or other grounds, if the journalist does comply with the subpoena, the breach of the non-disclosure contract is legally excused and cannot be a ground for the journalist to be legally liable to the informant.