'Knocked into a cocked hat' only makes any sense if you know what cocked hats are. These were hats, popular at the end of the 18th century, that had turned up (i.e. cocked) brims. They were usually tricorn (i.e. three-cornered) hats and were often worn as part of some form of official regalia.
The 'Toby jugs' that are still commonplace household ornaments in the UK were usually modelled wearing cocked hats.