On the PCT when you pass through National Parks the trail goes through backcountry areas where primitive camping is freely allowed. In Yosemite you get a permit for your entry point, but once past there you can camp where you will. There are few designated camp areas, though there are several bear boxes that encourage people to camp nearby.
The CDT in Glacier, Yellowstone and RMNP is different. Because of the grizzlies in the Rockies, there is no free camping in the NPs (except in Glacier where climbers can get undesignated permits in areas where there are no campsites). In the two northernmost CDT Parks, you are required to camp where there is a bearpole. If there is too much snow on the ground, so the bearpoles are not high enough, you won’t be able to camp at certain campsites. When we hiked south in 1999, there were a couple of campsites that were closed entirely, and one that had only one site out of four that was snow free. Fortunately there were no other backpackers that early in the year (late June) so there was no competition. You may also find campsites closed if there are bears actively in the area. Thus they are not likely to ever allow CDT hikers to camp without specific permits.
In Glacier the campsites are more like campgrounds - with 4 - 8 separate tentsites. Multiple campers share the cooking area and outhouses. In Yellowstone only one tent goes at each campsite. There are more of them, sometimes only a few miles apart, but some are restricted to groups or horses.
If you are in the NPs during popular periods, you may have to wait a few days to get a permit (or go a different direction in Glacier). Remember that short term backpackers may be making advance reservations. Glacier has an online site that shows what campsites are available – but when there is still snow on the ground it may not be useful since they won’t know in advance when the campsites will open up and so won’t give advance permits.
I think the fine is $200 or 250 for camping without a valid permit. There are rangers out checking - we ran into them in both Glacier and Yellowstone.
Ginny