Smart switch using 2 wire romex
There are a number of possible solutions including replacing the switch loop and smart switches that use ground (allowed if designed and tested to do so). But I'll suggest another solution:
Two Smart Switches
Put the main smart switch - which would actually have the WiFi transceiver, etc. - in Junction Box 2. There is constant power there, so any smart switch will work just fine. Wire it up to incoming power and the light fixture.
Install a smart remote to replace the existing switch. Depending on how it works, it may be:

Battery power - Cap the wires on both ends.
Constant power - Change the switch loop in Junction Box 2 to have constant power instead of connecting to the light fixture. The remote will use this to get power and (depending on design) to communicate with the main smart switch. But it won't actually switch the fixture - the main smart switch will do this.

The only problem with this is if Junction Box 2 is in a really awkward place. If it is hidden behind furniture then it doesn't matter. If it is near other switches then it will look just fine. The only problem is if it is in a weird place where a blank cover plate blends in with the surroundings but an actual switch would look out of place.