Is it possible to flag Settlement placements as personal?
Try setting up a bed on the second floor, deconstructing the stairs, and building a neighboring, unattached structure (or just a plain wooden staircase) that you can scale and use to jump over to your luxurious second floor bedroom.
Sorry Dogmeat, not THIS time. Find your own bed.
Try assigning Danse or Strong (assuming you have one of them) to the bed you want. Those two, maybe some others, don't sleep so you can keep their bed as your own as they never use it. You can use it as normal.
I've read that you can assign settlers to beds, so if you stay on top of which settlers you've assigned to which beds, you should be able to keep the people you've lovingly helped out of your bed.