TL;DR Not legally, and there are better options available.
Frame Challenge
USB was designed to connect computers and peripherals - mice, keyboards, storage devices, audio-visual equipment, etc. Over time it has become the universal 5V power supply, replacing numerous different types of power packs for electronic devices. But the intent was short distance computer to device communications. When powered from a wall wart or from a receptacle with integral USB, the "computer to device communications" part falls away. Which really should just leave convenience charging of devices that are a computer by themselves (cell phones, tablets, some full computers using high power USB C) or charging of battery-powered non-computer devices (e.g., flashlights, emergency battery power packs for other devices) or powering small stand-alone devices (simply in place of some other wall wart - i.e., just to make things easier because "everyone has USB wall warts lying around).
None of these cases normally calls for long-distance behind-the-wall wiring of power. Which leads to a common abuse of USB: Using USB for power + WiFi for networking. Why do people do that? Because USB is readily available for power - any standard receptacle (integral or with a wall wart) or a battery power-pack or a computer. And WiFi is readily available for communications. It sounds great on paper: As long as you have regular 120V power nearby and WiFi within range, you can plug in a video camera, security sensor, doorbell, etc. But there are a lot of problems with this:
- If you need to go more than ~ 15 feet, USB cables are harder to find, and chaining the cheapies doesn't work well.
- USB cables are not designed to be run through walls. In particular, you can't run just the wire and then put on the ends, the way you can with twisted pair Ethernet.
- Any networking is subject to a deliberate router hack or disconnect. But WiFi is vulnerable to routine direct replacement (new default SSID and password), deliberate factory reset to solve problems (assuming there is a factory-default SSID and password that was changed for security purposes) and other problems. Wired networking is only subject to wiring issues (which also affect power via USB).
The good news is that there is a technology designed specifically for this situation: Power over Ethernet.
- Long distance - 100 meters (328 feet)
- Cables (if properly rated) can be safely run inside walls, ceilings, etc.
- Cables can be run between punched-down jacks with factory assembled patch cables between the jacks and devices.
- High speed connections (1 Gig. with nothing special, higher speeds possible).
- Power source can be located in a secure location (e.g., PoE switch next to the router in a secure closet).
- Multiple devices can be powered from a single 120V connection (e.g., 8 or 16 devices on a single PoE switch).
Original answer:
There are two kinds of wire/connections/etc. in most US buildings:
120V/240V AC. This includes every standard 15A or 20A receptacle, whether it includes USB or not, most light fixtures, light switches, bigger receptacles (e.g., 30A for dryer, 40A for oven, etc.), junction boxes (connecting the wires between all those devices), main panel, subpanel, etc. Everything inside these boxes/devices/panels must be able to coexist in 120V/240V land. Which means proper insulation, design and certification (e.g., UL or ETL listing).
Low voltage. This includes telephones (POTS), ethernet and other network cables, coaxial cable (for TV or networking), alarm cable, HVAC thermostat wiring, doorbell wiring, speaker cables, HDMI and other video cables between TVs, computers and other devices, etc.
And never the twain shall meet.
Any transition has to be done in an approved way. That can be a receptacle that includes low voltage USB connections on the outside. That can be a doorbell/thermostat transformer that is mounted to a metal junction box so that it gets 120V power from inside a box and provides low voltage outside the box. But it can't, by definition, include a USB cable inside a junction box (i.e., inside the 120V/240V domain) because standard USB cables - and the devices they connect to - are not designed for that use.
The quick & easy fix is to do what alarm companies have done for a long time. Plug in a wall wart (or in the case of USB, yes you can use a receptacle with a built-in USB connector) and then run a cable from the wall wart or USB connector around outside the box (even "poke through the wall just outside the box) and fish it up or down to where you need it.
But really USB is the wrong tool for that. USB cables are simply not designed for long distances and permanent installations. If the goal is to power a remote device such as a video camera that requires data as well as power, then take a look at power over ethernet. Power over ethernet is designed for much longer distances than USB and combines data and power - with your USB-to-receptacle idea you are only getting power and, I suspect, trying to get data over WiFi which raises a lot of concerns. Note that power over ethernet is still low voltage, but the infrastructure is available to handle long runs and permanent installations properly, unlike USB. If your goal is to simply power some device that does not have any communications needs, then you may be better off with something other than USB - e.g., a traditional wall wart (like for an alarm system) that can be extended with one-pair cable over long distances rather than using USB cables.