As the two posts above me have said, it would have to be a very different "WWII". Perhaps if the Soviet Union went to war with Militarist Japan in the late 30s, or if Japan went to war with the UK, Holland, etc. (perhaps as a result of the Tientsin Incident in 1940?) and was never allied with Nazi Germany, then it is easy enough to imagine a circumstance in which a tactical defeat leads to the loss of all Japanese gains since 1937, or perhaps since 1931, but in which Japan retains the older colonies. Neither of these enemies or coalition of enemies would have the power, or indeed the interest, to totally defeat Militarist Japan to the point of unconditional surrender. The Soviet Union in particular lacked a powerful navy, and could never force Japan to give up control of Taiwan in particular, and Korea would be an awful slog. I have thought a bit about a total war between Militarist Japan and the USSR in the late 1930s before, and I think it might plausibly end with Japan being forced to give up Manchuria and likely even her prior concessions in China proper, but retaining everything else, and perhaps even winning control of the entirety of Sakhalin Island (that is, adding "Sagaren" to the Empire) as a sort of consolation prize. It should be noted that even in this scenario, I think Japan would be forced to give up Korea in a few decades as a result of the global decolonization drive, but Korea and Taiwan would be retained long after this "WWII".
However, if the OP's mention of "WWII" means that Militarist Japan has to be allied with Nazi Germany and has to start the Pacific War as in OTL, then I think it is impossible.