Actually, B and D are correct.
When you are asking about "a quarter," you are asking about only one quarter. While in the if-clause, the first clause, the quarter is one of many, in the second clause this quarter is referred to specifically. The pronoun reference in the second clause, to that one quarter, would be "it," to be specific, as in B and D.
You might change the first clause to: "If you have any quarters," or "If you have some quarters." In this case, the second clause could be, "could you lend me one," or "can I borrow one." "One" here refers to an indefinite one of many.
After you have asked your question, the possessor (or non-possessor) of the quarter could respond:
"Yes, I have one," or "Sorry, I don't have one."
In this case, the responder is referring to any quarter of an infinite possible supply of quarters, whereas the first speaker -- in the second clause -- was asking about just the one quarter that he/she might borrow.
Here are some additional natural ways of asking:
Do you have some/any change? Could I please borrow a quarter?
If you have some/any change, do you have a quarter I can borrow?
Do you have a quarter I could borrow?