Congress did exactly this in the war of 1812.
Normally, laws passed by Congress must be published after being made. In 1789, the First Congress instructed the Secretary of State with the duty of printing new statutes at least three newspapers, and the current law puts it in the hands of the Archivist of the United States; in between, there have been variations.
On March 3, 1811, Congress passed a law saying simply:
Be it enacted by the Senate and House of Representatives of the United States of America in Congress assembled, That this act, and the act passed during the present session of Congress, entitled “An act to enable the President of the United States, under certain contingencies, to take possession of the country lying east of the river Perdido, and south of the state of Georgia and the Mississippi territory, and for other purposes,” and the declaration accompanying the same, be not printed or published, until the end of the next session of Congress, unless directed by the President of the United States, any law or usage to the contrary notwithstanding.
This overrode the normal publication rules in order to hide the existence of the cited earlier law, and of its own existence. The proceedings in Congress also took place in secret session, including the signing of the bills by the President, James Madison. As the title suggests, the earlier statute authorized Madison to use military force to take possession of the disputed territory (which was also claimed by Spain), establish a provisional government there, and use $100k of newly appropriated funds to do so. A further law of 1813, with the same secrecy provision, extended the territory and gave $20k more.
These statutes were not published until 1818, after the war had ended and a further law reformed the publication of statute law in general. The supposed secrecy was also compromised in practice by the fact that the annexation of West Florida was widely known once it started happening.
As far as we know, Congress has not experimented any further with suspending publication of its legislative activity. It is allowed to meet in secret session, and the Constitution allows secret material to be omitted from the official journal. Nowadays, we know pretty well when secret sessions have taken place, even if we don't know what happened during them. It would be practically very hard for Congress to hide the fact that it had met and passed a law.
The closest modern counterpart is not a secret act, but the use of a "classified schedule of authorizations" or "classified annex" to direct spending on things that Congress does not wish to reveal. For example, in the Consolidated Appropriations Act, 2022 (1068 page PDF), there are references like:
- "there is appropriated $125,000,000, for an additional amount for 'National Defense Stockpile Transaction Fund', to remain available until September 30, 2024, which shall only be used for the acquisition and retention of certain materials, as specified in the classified annex accompanying this Act"
- "The amounts authorized to be appropriated under section 101 for the conduct of the intelligence activities of the elements listed in paragraphs (1) through (17) of section 101, are those specified in the classified Schedule of Authorizations prepared to accompany this division."
The second bullet point covers billions of dollars of total spending, but it is not revealed that we are spending $7.18bn on a project to explode the moon, or whatever. So in this appropriations case, your hypothetical is pretty real: Congress could pass emergency legislation authorizing spending on something, without revealing what the something was.
Other kinds of laws would raise their own issues. For example, a secret criminal statute would very likely fall foul of the Constitutional prohibition on ex post facto laws. The concept of a secret law is in many ways objectionable - natural justice, interference with democratic accountability, etc. - which makes it politically difficult as well as legally questionable.