There are two approaches you can take to doing this, maybe three.
1) A tunnel.
Find something that can capture and broadcast local signals, get one both ends, send them over the internet, hope
https://www.gamasutra.com/view/feature/3374/the_internet_sucks_or_what_i_.php?print=1 does not burn you too hard (it is old but physics is physics and a game built for local play tends not to be built assuming you get as many dropped packets and ping issues as the average internet session -- if your local area is getting interference enough to bother someone close enough that you could throw the device and hit them in the head then probably don't want to be stopping there to play games).
I don't know what the 3ds has for this -- the DS quite notably used a fairly custom protocol that most basic network cards will have a really hard time trying to capture. If the signal is a normal one seen by normal networks then you have more options, if not then time to bust out the custom specialist hardware and/or soldering iron.
Done lots with the original xbox, the gamecube (8 player double dash being the stuff of legends), arguably the 360 (though Microsoft tried to slow it) and PC games with LAN options, though in all cases you are limited to whatever exists for local multiplayer which might not be as nice as what is available for full fat online and is also tricky to handle (give me a VPN into your local network to play games and I have basically a machine on your local network).
2) You hack the game to have its own online network options. Arguably done on consoles as far back as the SNES with the likes of XBAND but still fraught with difficulty, and you might have to add your own mitigations in for the link above to deal with ping as most local play will not have bothered with anything like it.
It is still well within the realm of reason to do it, however I don't think I have seen it done outside of maybe some co-op hacks, and someone did once spend a lot of time looking into I think it was SNES mario kart to have many player races but that was using emulators and intercepting player locations there.
Whether you can adapt the existing local play for network use or would want to go from scratch (if there is an AI mode you might be able to subvert then they can make good targets to introduce player actions to) I don't know.
The possible third is remote control. This is also the way many modern emulators will do 1) to avoid the problems of
https://www.gamasutra.com/view/feature/3374/the_internet_sucks_or_what_i_.php?print=1 (basically send a copy of the joining player's savestate and save to the host, have it load up with the host so the host is emulating multiple systems on the same system, no lag/dropped packet issues that way). The other option of kaillera style multiplayer where you just send the screen image and take control inputs in is not really available for most handheld games -- they tend not to have multiple players on one system, but there are pass the controller games like worms and advance wars, or oddities like some of the things warioware did with multiple player on one console minigames). For TV type consoles then as most local multiplayer is literally just a controller input and screen with everything handled internally then such things are far easier.
In this case I might have two 3ds locally playing a game but have remote control options sent from wherever in the world and stream audio and video back the other way, possibly even from another 3ds.