I see these words use interchangeably in various contexts. Is there a formal difference or preference?
Please supply relevant examples.
You have probably already checked the dictionary for definitions of paucity, scarcity, and dearth. They all basically mean "a lack of something," and the fact that each definition references the others attests to their interchangeable utility. However, if there weren't subtle distinctions in meaning, we probably wouldn't bother to have three formal words for the same thing, so your question is a good one.
If I were to order them from least lacking to most lacking, I would say paucity->scarcity->dearth, based on their respective definitions.
If you have a paucity of pumpkins, you would have just a few (but your neighbor might have many). A scarcity of pumpkins would mean that pumpkins are quite rare, perhaps due to green-oozy pumpkin disease (that is a made-up disease), and you might reserve one for a special occasion. Finally, a dearth of pumpkins suggests that pumpkins are nowhere to be found, and there will certainly be no jack-o-lanterns on Halloween.