It depends, How much do pencils cost is plural, but when you add a specific number it groups them together, so how much does a group cost, the group being twenty pencils. It changes to a collective noun, essentially. Of you took out pencils, and gesture towards them instead, you could say how much does twenty cost, how much do twenty cost sounds weird. All that with the implication of them, that to which you are gesturing. English speaker from America answer.