They eventually stand still if you hold right click on them for long enough with the bucket, then when it says they're stressed just let go of right click for a moment until it says they can be milked again and then try again. I've been able to milk the wild goat I caught reliably like this, though I do have them in a small 5x5 pen where I can be standing in the center and always be in range of them. If you have a really large pen I can see why you'd have issues since it'd be tough to stay in range of them for long enough to get them to stand still, but you definitely don't need to trap them in a 1x1 cage.