Has anyone received this high honor while retreating in the face of the enemy?
Yes, if you take into account "fighting retreats." Perhaps the most famous ones come from the Korean War, one of America's less successful wars.
The battle of Chosin Reservoir in Korea was widely considered a retreat by the U.S. 1st Marine Division and 7th Infantry Division. This was even though the Marine Commander, General Oliver P. Smith put a brave face on it by saying something like, "Gentlemen, we are not retreating. We are attacking in a new direction."
Here is a list of Congressional Medal of Honor Recipients that include at least three officers of that retreat, Lt. Col. Don Faith (of the 7th infantry), and Captain William Barber and Sgt. Robert Kennemore (1st Marine).
Also, Major General William Dean commanding officer of the 24th Division during the early days, whose "fighting retreat" (which he personally led, wielding a bazooka and destroying an enemy tank), bought enough time for the rest of the U.N. forces to arrive.