From Latin penicillus 'little tail, paintbrush' — the graphite writing stick sense only dates from the 1560s.
A thin cylindrical instrument of graphite enclosed in wood, used for writing or drawing.
From Old French pincel 'paintbrush,' from Latin penicillus 'paintbrush, little tail,' diminutive of peniculus, diminutive of penis 'tail.' Yes — pencil ultimately derives from the Latin word for 'tail.' The shift from paintbrush to graphite writing stick happened in the 16th century. Key roots: penis (Latin: "tail").
Penicillin is named from the same root — Alexander Fleming noted that the Penicillium mold had brush-like (penicillus) structures. So both pencils and penicillin are, etymologically, 'little tails.'