You can’t camp within 3 miles of a road. You’re supposed to be at least 100 feet off the trail / away from water. Other than that, except for a few special, high traffic areas, you can camp pretty much anywhere.
The most popular trail (John Muir/Mist) starting in Yosemite Valley leads to / through Little Yosemite Valley. You cannot stop between the trailhead and LYV. If you don’t want to stay in LYV’s designated camping area, you have to hike a certain distance beyond it before you can stop. I think it’s two miles, but I’m not sure. All of that info is available on the NPS Yosemite site. I generally enter the backcountry through LYV, but I start at Glacier Point on the Panorama Trail. The distance to LYV is slightly longer, but (except for one 1.5 mile section) it's mostly downhill. The John Muir Trail gains a couple of thousand feet in its first three miles.
There are several great 3-4 routes from Tuolumne Meadows to Yosemite Valley, but they require a shuttle ride. Firm up your dates and check to see if you can work around the fall YARTS schedule:
www.yarts.com or 1-877-989-2787. Summer schedule ends August 31.
If you can't use the shuttle, I'd suggest a loop starting at one of the Tioga Road trailheads near Tuolumne Meadows. But you probably need to figure out your shuttle options first, and then ask for advice that fits.