Wouldn't that be the war crime of perfidy, similar to when the US used a secret plane painted as a civilian aircraft to sink one of the Venezuelan boats 9/2025?
I'm not quite sure if just putting up a military flag on a civilian transport ship makes it count as a warship or not though.