I’m going to answer in 2 parts.
Firstly, I’ve never heard of a healthy hog being attacked by magpies before and therefore if this is the case I suspect it’s ill and needs expert attention. Also this sounds as if the hog was out in the daytime which is not normal. If you contact the BHPS they will give you a list of carers in your area and you should contact one for help and advice asap.
Please don’t assume that because you’ve got it in captivity and it’s eating that there is nothing wrong with it. People frequently do and find a dead hog on their hands a few days later. Stress of captivity can cause a lot problems to get worse.
Secondly, if you have a badger visiting your garden, then no you cannot encourage your hog to come. To be frank it’s unlikely it would anyway once it knew the badger was there. Badgers can and absolutely will kill hedgehogs in a very nasty way. A hungry fox will also have a go.
Hope that answers your queries