No, it doesn't work like that (unless your long layover is actually a stopover)
Say you are flying ABC-tokyo-XYZ, XYZ being the final destination that you don't want to go to
At ABC airport, the airline checks if you have a valid visa to XYZ. No visa = no flight to tokyo
they don't care if you have a ticket from tokyo-somewhereelse - they will get fined by XYZ if you manage to land on XYZ without a visa, fined by Japan if you get stuck in Japan because u can't get to XYZ (and that airline is responsible to transport you back to ABC)
Best case is to talk to airline, check if you can change your ticket from XYZ to something else