Translation:Does anyone have a pencil?
is "heeft iemand een potlood" unnatural?
That's also accepted, but with 'er' is more natural. :)
What about: "Does anyone have a pencil here?"
No, "er" doesn't mean "here" or "there" in this case, it's used as a placeholder for an indefinite subject. See here for details: https://www.duolingo.com/comment/25000664
If you wrote: "Heeft hier iemand een potlood?", then your suggestion would make sense.