The story
The mushroom sense (sense 2) arose because the mature fruiting body of the mushroom resembles a literal pepper pot (sense 1) and the spores that fly out of it resemble the granules of pepper being dispensed. The feisty-person sense (sense 4) arose because such a person figuratively adds spice to life, like a literal pepper pot (sense 1) does.
Etymology from Wiktionary, CC BY-SA 4.0.