Counter conditioning is the most successful strategy for this IMO. You arent using treats to make the dog obedient, but to change how the dog views things.
Sounds like there were two things going on: a likely poorly socialized dog in a new location, still unsettled from the stress of rehoming, and dealing with a new person. Trigger stacking. I would probably work on both separately.
Currently the most commonly recommended protocol is the following:
https://grishastewart.com/bat-overview/
Basically, It relies on introducing dogs to their triggers at 'safe' distances where the dog isn't reacting, and then rewarding them for their non-reaction by moving further away from the trigger. It's a stress-relief cycle, no treats required. It works really well, but sometimes you don't have the option to watch things from 100 or 200 m away or whatever the non reaction distance is.
My suggestion would be probably more counter conditioning. Put the dog on leash, maybe tied to a post. Obviously, make sure the dog is comfortable being tied out before you bring in a friend. Go, chat with the person, both of you sitting on chairs a bit away, at a distance the dog isn't reacting to you. Toss a treat or walk over and toss a treat, not even looking at the dog. Have your friend stand, toss another treat. Both of you walk away, giving a bit of distance. For treats - think a piece of left over dinner meat or cheese. Something really good to get past the dog's nerves. Really quickly the strange human standing up
should have a positive emotional reaction, not a negative emotional reaction. You want to reward the dog BEFORE it reacts negatively. If your friend standing is still too big of a trigger - maybe move further away, or have your friend just pretend to prepare to stand, shifting their legs, raising their arms, whatever. I would probably chose a friend who listens to your instructions more reliably to start this training :)
The idea is to change the emotional response from 'people are scary' to 'wow, people make food rain down from the sky!' so the dog stops thinking every small movement is a cause for concern.
Similarly if you have issues with him barking at neighbours, have him on leash, right when you see the neighbour, have him look at you and give the treat BEFORE he reacts. You are changing the default response from 'omg threat!' to 'oh good, a person, let me check in with my human'.
As the fear fades, you can move closer, fade out the rewards etc.
Keep in mind you are working against breed traits though. It's pretty normal for a
LGD to bark at anything 'weird' when guarding their 'flock' even if the flock is a human who wishes they wouldn't. My goal for being in the backyard around neighbours would be one alert bark and done, instead of hysterical continued barking.
Moving from pure counter conditioning to training, another common recommendation is the Look at That game, which teaches your dog to observe a distraction, ignore it, then look at you for direction. It can be started in your kitchen. Here's a service dog trainer showing how it works.
Some people would suggest extinguishing the behaviour (applying a negative stimulus/punishment, for example, using a pinch or choke collar to correct the dog until dog stops doing it) but that wouldn't be my suggestion because of the risk of backlash for a fear based behaviour. It's pretty easy to end up with a dog who is still afraid of the trigger, but has also learned not to communicate the fear, and that's where you start to risk no warning bites if someone with bad dog-reading skills approaches the dog suddenly thinking quiet dog = friendly dog. Or, depending on the level of the fear, redirection up the leash at the handler.