If a trail gets a lot of use then there tend to be a fair number of established campsites, which you should use to minimize your impact. However, in more populated areas it is usually wise to camp a mile or so away from roads, utility rights of way, and the like - or you may awaken at night to the sound of ATVs or drunken high school kids. This is especially true on weekends.
If there are no established campsites, then you usually go about 60 meters off of the trail and set up camp, following Leave No trace practices. This can be difficult on routes like the New England Trail, which traverses a lot of privately held land. It takes a fair bit of planning to find out who the landowners are, and then get permission to camp.
If you are talking about a trail like the East Coast Greenway, which traverses urban areas, you might find that Airbnb is your best option.