Technically, you can use friends on anyone from anywhere
The friends spell has a range of Self and states:
For the duration, you have advantage on all Charisma checks directed at one creature of your choice that isn't hostile toward you. [...]
The description puts no limit or restriction on the "one creature of your choice" besides that that must not be hostile toward you, they can be at any range, on any plane of existence whatsoever.
A possible counterargument would be that the affected creature is a target and so you need a clear path to them
However, what counts as a target for a spell is greatly debated and not well agreed upon. So say friends does require a clear path to the affected creature. I would then bring up the scrying spell which also has a range of Self is discussed in the question "Does the Scrying spell require you to have a clear path to the target in order to work?." If friends requires a clear path then scrying likely would as well which is... problematic at the very least. Thus, we assume friends can target anybody, anywhere.
What happens when friends ends? Technically, the affected creature becomes hostile
Quoting again the spell (emphasis mine):
[...] When the spell ends, the creature realizes that you used magic to influence its mood and becomes hostile toward you. [...]
Technically, the spell ending forces the creature to become hostile toward you, this is because there's not a causal link between the creature realizing you influenced its mood and it becoming hostile toward you. The former is a not a requirement for the latter to occur, reading the text literally. I believe this is a rather absurd interpretation and it is not what I, as a GM, would follow.
How I would run this at my tables
I would rule that if you use this spell on somebody and never even direct a Charisma check at them, then you have not influenced their mood and so they have no reason to become hostile toward you. I would rule this on the basis of realism and to avoid making this spell just absurd.
Keep in mind the amount of leeway the GM has with friends
The spell states:
[...] A creature prone to violence might attack you. Another creature might seek retribution in other ways (at the DM's discretion), depending on the nature of your interaction with it.
You haven't even interacted with the creature in any meaningful way, you cast a spell that affected them but they don't know who you are, nor have you directed any Charisma checks at them. Furthermore, it is entirely up to the GM how a creature responds to and uses this newfound hostility, assuming they do anything at all.