My horses used to have the same problem. You need to give them something to do to take their minds off their friends. I personally wouldn't do the whole treat thing, just because it is a bribe - and bribes don't work on horses and you really aren't accomplishing anything by bribing them.
Lead ro ride him away from the barn and if there is grass somewhere, let him eat for a few minutes. Then start groundwork him for a few minutes and if he tries to be with his friends, back him. Swing your leadrope hard and back him up. But I don't suggest that if you have hardware on your leadrope, because it isn't helping in the teaching of the horse - it may actually cause him to be afraid, and you do not want that.
Once you get on na dhe is still being a butt, use an extr rope or the extra off of your reins and use it like a romel. First use a warning far away from his withithers - touch both your shoulders with the romel and make sound so he can hear it. If he hasn't gone, get closer to his withers, and slap your waist or thighs. If he still hasn't gone, he doesn't have any chances left - and now is when you slap his withers. First, start off with a soft slap, any speed. If he still isn't going, continue the same speed, but increase the pressure of the slapping.
This works very well with my horse and I do recommend it. My horse, as soon as he hears that first warning he is done messing around and he l is listening like there is no tomorrow.
If he wants to back up, try facing him towards his friends and back up. Or if he really insists on backing up away from his trail buddies, back him up quite a bit then stop.
If he doesn't stop backing up or if he doesn't listen to the romel technique or goes forward in the wrong direction, do the emergency stop, but don't get off. Reach up and pull his nose to your knee and hold it there until he stops movin, then hold it for a few seconds longer and then release. Then to the same to the other side and if you need to, do this twice on both sides. This just gets control of his motions and stops moving his feet. He may keep moving in a little circle with his nose o your knee, but just hold it there until he stops moving, and the first few times when you do this, then as soon as he stops moving release. But when you go to flex the other side, hold it to your knee until HE gives his head. You shouldn't hold it there and then give it back without him doing anything. You want him to give his head to you. This helps give you control, show who's boss, and simmer him down.