The situation after someone has been beaten in a battle of skills.
During the early days of sailing, a ship's position was charted by marking three plotting lines on a map. The ship should be at the junction of all three but, since navigation was in its infancy, the lines often produced a little triangle. The ship was reckoned to then be in the middle of the triangle. The triangle itself was known as a cocked hat after its resemblance to the common three-cornered hat of the times. On this basis the expression originally is said to have implied a sense of uncertainty - of not knowing where you were.
Alternative: In certain forms of the game of nine-pin bowling, three pins were set up in a triangular shape. The rest were set up around and the object was to knock these down and leave the three standing. The three reminded people of a three-cornered or cocked hat.
Alternative: The cocked hat of the 18th century was merely the 16th century Puritan hat with the brim rolled up or cocked into a triangular shape. This was a dramatic change which later took on the inference of defeat.