They generally throw it away in the place where they're opening it. Usually, you don't open stuff up until you get home, and I would hope you have a trash can there.
The big factor for foreigners is that people don't normally eat and drink while walking down the street; it's generally considered rude. If they stop and sit somewhere and eat or drink there, they keep their trash with them instead of throwing it on the ground like many other countries. If you're just getting stuff from a convenience store, you can usually throw stuff in the trash cans there.
Most stuff I've seen doesn't have an absurd amount of disposable packaging, but that is really common with the gift boxes of sweets that are commonly bought at stations and given as gifts. But these you don't normally eat in public.
You dispose of it where you bought it, or you don't open it until you get home, or you act like a good hiker who is out in the wilderness, and pack up your trash to bring home with you where you can properly dispose of it.
I always found it amazing that Japanese cities manage to stay so clean without public trash cans everywhere. It's a reminder that you have to solve the social and cultural problems first: if people think it's ok to throw trash on the ground, it doesn't matter how many public trash cans you have.
It's also useful to remember that the general lack of public trash bins isn't a long-standing part of Japanese culture: it only dates to the 1990s, when public trash bins were used for the infamous Sarin gas attack. After that, most bins in cities were removed. What's cultural is what happened later: the cities didn't turn into trash heaps, because people simply took their trash home or otherwise waited to find a suitable place to dispose of it.