One possibility is to have Japan go the route of China and actively resist Commodore Perry's opening of Japan in an attempt to maintain their policy of isolation. Perry is then forced to utilize extreme force, destroying a large chunk of Edo and perhaps forcing the Shogunate to sign a humiliating treaty similiar to those signed by China.
With this kind of "opening" in Japan, other major powers swoop in to gain their own commercial treaties with Japan, effectively carving Japan into spheres of influence over a period of time.
Meanwhile Japan attempts to modernize, but in a very decentralized way, with each domain choosing a different model, including a very modest reform program of the Tokugawa. Meanwhile due to Japan's humiliation at the hands of the foreigners, internal discontent versus the Shogunate is mounting, with the Emperor becoming more and more of a figurehead for this discontent. Eventually this resistance results in a much larger shishi movement (an otl group of samurai fiercely loyal to the emperor and fiercely anti-foreign) trying to overthrow the Shogunate and succeeding due to larger numbers (in OTL they tried this but failed).
Using the emperor as a figurehead, the shishi succeed in overthrowing the Shogunate and immediately begin campaigning to kick the foreigners out of Japan in a kind of "Japanese Boxer Rebellion". They are aided in this plight by the various modernized domains and their armies, but ultimately an alliance of Foreign powers (USA, UK, France, Russia) arrives on scene to defeat the pro-emperor forces and restore the Shogunate. The treaty that ends this Japanese Boxer Rebellion restores the Shogunate, regulates the Emperor to ceremonial duties only, and breaks the power of the modernizing daimyo effectively dividing Japan into foreign spheres of influence.
thoughts?