The only way for Japan to keep Taiwan is to avoid the Pacific War.
Even George Kerr, the man in the State Department most critical of the return of the island to China wrote in *Formosa Betrayed* that during World War II (and he is referring to the time *before* the Cairo Conference) "Three alternatives were evident. In theory the island might be made independent and given self-government, but in practice this would be difficult to bring about, even if the Formosans wanted it and the Allies agreed. (Surely China would object.) A second course would ensure the prompt transfer of Formosa to China, to satisfy loud Chinese claims that it was a "lost province." A third program would provide for a temporary Allied trusteeship, during which the Formosans themselves would prepare for a plebiscite to determine their ultimate political fate."
http://homepage.usask.ca/~llr130/taiwanlibrary/kerr/chap01.htm
Note that Kerr does not even list letting Japan keep the island as an option. True, the third option listed involves an eventual plebescite, and *theoretically* a plebescite could go in favor of Japan. But in practice it almost certainly wouldn't--it was only *after* years of Nationalist misrule
https://en.wikipedia.org/wiki/February_28_Incident that nostalgia for Japanese rule as "the good old days" could gain any strength on the island.
And in any event, the third option was unlikely to be adopted, given that promising China Taiwan was an easy way of satisfying the Chinese (compared to making China more of a military priority) in wartime diplomacy. Indeed, Japan was lucky to eventually keep the Ryukyus, even though its claim for them (both in terms of history and ethnic affinity) was much stronger than for Taiwan.
https://www.alternatehistory.com/forum/threads/ryukyu-liu-chiu-islands-republic-of-china.392606/