I had a Rottweiler living accross the road from me that was always on the loose and showed signs of protective aggression such as barking at strangers and other dogs etc.
Naturally I wasn't very impressed with the owners negligence or with his attitude to the situation.
I'd complained to council several times but the dog was never out when they came, so nothing was ever done about it.
I had several occasions where I'd come home late at night and surprised the dog in my back yard and the only way for him to get out was to go past me, it was not an ideal situation.
After talking to owner with no change I decided to take the matter in my own hands.
I got a small bell and when he was in my yard I'd ring the bell and drop a treat for him (pavlonian conditioning) after a few days he was starting to come the sound of the bell and about two weeks later he started camping out on my veranda in preference to his own house.
I started to add a bit of basic training such as sit, stay, shake hands and he learned very fast - he was an intelligent dog, even more intelligent than I'd expected.
I then taught him food refusal - only very basic not like a police or military dog, where I could make him hold out until I gave him the OK to eat.
After a few weeks of training he associated my yard as his patch and whenever someone came prowling at night ( which happened too often where I lived) he would turn up and scare them off.
In the end if the owner called him he would just stay with me and ignore the owner, I think he saw me as his pack leader and the owner as another dog.
After a few failed attempts to get him to come when called the owner dragged him home and started to lock him up from that point.
I tested him one time to see if would escape when I called him and he did, but I let it go a that, I'd made my point by then.
If you let a dog roam free it's loyalty lies with any Bozo with a bit of food.