(A). A hat with the brim turned, like that of a bishop, dean, etc. It is also applied to the chapeau bras, and the military full-dress hat, pointed before and behind, and rising to a point at the crown, the chapeaù à cornu. “Cock” in this phrase means to turn; cocked, turned up.
Knocked into a cocked hat. In the game of nine-pins, three pins were set up in the form of a triangle, and when all the pins except these three were knocked down, the set was technically said to be “knocked into a cocked hat.” Hence, utterly out of all shape or plumb. A somewhat similar phrase is “Knocked into the middle of next week.”
Source: Dictionary of Phrase and Fable, E. Cobham Brewer, 1894