>>1891978In most of the developed world; resting overnight (whether in an abandoned shack, set up or makeshift shelter) is not going to ever land you a fine. The law is either permissive or vague enough just to really apply to the most egregious offenders (like sleeping in a camper van in a parking lot for multiple days).
If your country is not a shithole (and you're not brown) then a simple "I'm far away from any accommodation and I don't feel safe riding at night in these conditions/with this gear. I'm gone by sunrise." is going to be more than enough for them to leave you alone. Unless you're being a darwin awards nominee by sleeping in a dangerous wildlife hotspot, in which case the ranger/police is probably going to offer you a lift to the nearest hostel or their station bench, whichever is closer.
I have slept by the roadside across the Balkans maybe 20 nights and have a circle of friends and acquaintances who do the same and who I've travelled with. NONE of us have had any serious problems with the authorities and the few contacts were resolved as described above.