In a formal and/or legal context, when you want to refer to a person's loved ones, what word or phrase would you use? I was thinking perhaps "next of kin", but checking various dictionaries, I get the feeling that that refers to family/relatives only, excluding close friends?
The law doesn't tend to talk much about "friends". A friend has no special rights. The category "friend" is too vague for laws to be written around it.
Formal English is mostly about using simple and clear words. Here, if you want to include close friends too, you could formally say "relatives and close friends".
But "loved ones" isn't informal. It would be correct to use "loved ones" in a formal newspaper article or an essay.