Many foreign navies have commissioned foreign shipyards to build warships and submarines for them. Most recently, Russia purchased to amphibious dock landing ships from France (that sale is currently suspended due to Russia's invasion of the Crimea). Also, it was reported this week that Australia is looking to foreign shipyards to build it a new class of submarines under the assumption that the Defense Ministry "wouldn't trust [Australian shipyards} to build a canoe." While it is true that the U.S. Navy has, from time to time, commissioned into the fleet captured war prizes (e.g. some gunboats captured in the Spanish-American War). Also, the U.S. Army, during World War I, purchased tanks and aircraft from Europoean manufacturers. But unlike its sister services, I am unaware that the U.S. Navy has ever requisitioned a foreign shipyard to build it a warship of any class. Is that correct? One period I'm uncertain about is the naval expansion preceding the Spanish-American War.
If you're willing to accept the Navy of South Carolina as being part of the US Navy, then the Indien/South Carolina, built in an Amsterdam shipyard in 1778, seems to meet your criteria. It was built to order as a warship rather than being converted from an existing merchant ship, for some government that eventually became the United States.
The only thing I'm not sure of was whether it was ordered directly by South Carolina or whether it was ordered by representatives of the Continental Congress and wound up being operated by the South Carolina navy as part of the incredible political maneuvering surrounding it.
Not sure if they qualify but the Asheville and Natchez were River Class frigates built in Canada in 1942, for the RN and RCN, transferred while still being built under the Reverse Lease Lend to the USN.
If they qualify there were also a number of Modified Flower corvettes transferred while being built. Others?
We still have an active shipyard on Guam and at Guantanamo. We have had other shipyards overseas in the past, but the rest of them have been turned over to the local government. The only exception is the shipyard on Pago Pago which was turned over to the Department of the Interior.
I suppose we have to exclude the Confederate Navy entirely, otherwise this question would be far too easy to answer.
At least in recent times, such an act would be in violation of the US Code Title 10, Subtitle C, Part IV, Chapter 633, 7309. The President can apparently waive this however.
All of the boats acquired during the Spanish-American war that were from overseas were just purchased. None that I can find were actually built for the United States Navy. This point in US Navy history is probably the point at which the largest percentage of United States Navy boats were of foreign construction. About 125,000 tons were purchased.
The National Defense Reserve Fleet contains numerous foreign built vessels, but again none were ordered by the US Navy at any point in time.
Since there is no clear answer here, I'll submit the SBX-1.
SBX-1 was at one point a boat of the Missile Defense Agency, part of the Department of Defense. As of 2018 the MDA presently has an Air Force General as its head, but SBX-1 is an oceangoing vessel with a clear combat purpose. SBX-1 hull started life as a CS-50 oceangoing platform. It was purchased from the Norwegian firm Moss Maritime. To make it more interesting that hull actually comes from Sevmash, a Russian company who made it in Severodvinsk. Final fitment was done in US ports located in Texas and Hawaii.
So it isn't a US Navy boat, but it was at one point part of the US military structure. It has no offensive capabilities either.
The US Navy has occasionally purchased existing ships that meet a specific need. As Eric Urban notes, US law requires the navy to use US yards for commissioned vessels, unless the president issues a waiver.
An example of a specialized ship acquired from outside the US is the Trieste, a deep diving bathyscaphe. Originally built in the 1950's by Auguste Piccard, designed in Switzerland with the final construction done in Italy. Trieste was at one point owned by the French Navy, later purchased by the US Navy as a deep diving exploration vessel. Trieste descended into the Challenger Deep to a record depth of over 10,000 meters, and also surveyed the remains of USS Thresher, a nuclear submarine that was lost.
When an improved version was commissioned by the US Navy, Trieste II, it was built at the Mare Island Navy yard, where a number of submarines had been built in WW2. Trieste II did use the original pressure sphere from Trieste, left over after Trieste's pressure sphere had been replaced with an improved version built by Krupp.
One example of a ship (sort of) that was built overseas after being commissioned by the US Navy was the USS Los Angeles, a dirigible built in 1923 by the Zeppelin Company, that was captained by Hugo Eckener on it's delivery voyage from Germany to Lakehurst, NJ. This was a replacement for a dirigible that was supposed to be given by Germany to the US as part of war reparations, but had been sabotaged by its crew. The Los Angeles had a trouble free career, unlike the US built dirigibles Akron, Macon, and Shenandoah, all of which were lost to crashes.
In this case, the navy did officially commission the building of a vessel that was constructed outside the country, although subsequent dirigibles for the US Navy were built in the US.