I was reading the recent TIL about the SMS Cap Trafalgar disguising itself as the HMS Carmania, only to be sunk by the actual HMS Carmania. Occuring in 1914, did that violate any of the laws of war?
Or was it the kind of thing that was frowned upon that might see less mercy to the losing side?
No, it's not a war crime to disguise a ship as that of another country. It's a technique called "sailing under a false flag", and as long as the ruse is abandoned and the ship's true flag raised before shots are fired, it's considered a ruse de guerre.
Examples of this happening are the St Nazaire Raid, which used the HMS Campbeltown, disguised as a German torpedo boat and filled with explosives, to ram the huge drydock located there.
The Kormoran, a German auxiliary cruiser, sailed as a Dutch merchantman; it wound up sinking the Australian light cruiser Sydney in the largest single naval loss of life that nation suffered in WWII.