If you don't have a reservation it's hard. You should hit the reservation.gov website every week looking for a cancellation, if you want a reservation. In summer walk ups/first come first serve sites go FAST, with lines starting at the kiosks very early in the morning. Showing up midweek helps some.
In the valley itself the only walk up campground is camp 4 and they changed how the reservations work - you have to get online the day before you arrive and enter a lottery. Outside the valley, Bridalveil and Hogdon meadow have first come/first serve sites. There are also national forest campgrounds on the way to Hetch Hetchy.
https://www.nps.gov/yose/planyourvisit/camp.htm