A pencil was an implement used in writing; generally made of wood and lead, and can also come in a coloured variety.
While Captain Edmund Blackadder was awaiting execution by firing squad, Baldrick brought him a bag of items with which he could make his escape. Rummaging through the contents, Blackadder found something he took to be a chisel, only to find it was a pencil. Baldrick told him it was to write a postcard with, telling him how the escape had gone. (BGF: Corporal Punishment)
Some time later, Blackadder was ordered to go over the top. To ovoid the risk of death, he chose to stick two pencil up his nostrils and put his underpants on his head, so as to feign madness. He had learnt this trick in the Sudan, but General Melchett was aware of the hoax and so Blackadder was forced to pretend his was simply demonstrating its fallacy to Baldrick. (BGF: Goodbyeee...)