Have a look at the searchforsites app, also campercontact, park4night. Have a look here for suggestions:
Any pub that has reasonable parking will be open to a request to stay overnight if you're eating or drinking there. They may ask for a fee but are usually happy if you patronise the place.
I doubt there would be much joy in the centres of the bigger cities but, for Edinburgh say, there are numerous campsites around the outskirts with good public transport links. Google is your friend!