"Do you have a pencil?"
Both mean "do you have a pencil", but using 持つ specifically asks whether they have a pencil on them at the moment, whereas ある asks whether they have a pencil in general. If you have a pencil at home but you aren't carrying it with you, then only ある would apply, not 持つ.
You're confusing the two verbs used for "have".
鉛筆を持っています。- I have a pencil (on me at this moment).
In this sentence, the pencil is the direct object. It is being possessed directly by the subject (which is commonly elided due to previous context). を is therefore the correct particle.
鉛筆があります。- I have a pencil (but I may or may not be carrying it).
This time, the pencil is the subject of the sentence. They are literally saying "there is a pencil". That is why が is used here.
The sentence you wrote is full of mistakes. The particle is written as は, you need a particle before verbs, in this case between えんぴつ and あります, です is only used in noun sentences, ある is a verb so you only need ありますか. So the correct sentence would be "あなたはえんぴつがありますか。", though you don't really need to use "あなた" in this context since it's obvious who you're talking to. And they can both work, though ありますか can also mean "is there".