I can find a literary reference; I have no idea whether the depiction of the anecdote is accurate. The reference is in the notes to La Gastronomie by Joseph de Berchoux, which was somehow famous in France in the 19th century and coined the word gastronomie. The poem was first published in 1801 (the edition I link to is from 1819). The notes look like they should be by a different person but I cannot find that person's name so they may be by Berchoux himself. The anecdote is in the notes to canto 2 page 51 verse 17 and starts at the bottom of page 51 (“M. Delille, en avril 1786, étant à dîner …”).
This is the same anecdote that is recounted in A Manual of Etiquette with Hints on Politeness and Good Breeding by “Daisy Eyebright” found by Mark Wallace. The anecdote is a long succession of faux pas committed by Abbot Cosson and pointed out by Abbot Delille (it seems that Stendhal mixed up the roles): about where to set one's napkin, about how to eat an egg, about how to cut bread, about how to drink coffee, about how to name various dishes and drinks, etc. The part about the egg is quoted below, but really the point is in the long succession of minute details that are only known to and observed by the high society.
Another literary source provides a historical perspective on the usage of breaking the shell of an egg. In Variétés Historiques et Littéraires vol. 7 by Édouard Fournier (published in 1855), in note 7 on L’Œuf de Pasques ou pascal, à M. le lieutenant civil by Jacques de Fonteny, Fournier writes (my translation):
One should refrain from breaking a full egg. Conversely one should hasten to break it as soon as the shell has been emptied. This was a sacred usage among the Romans (Pliny, book 28, ch. 2), which we have kept as a simple rule of etiquette: “After your soup, what did you eat? asked Abbot Delille to Abbot Cosson in the famous conversation reported by Berchoux. — A fresh egg, answered the other. — And what did you do with the shell? — Like everyone does, I left it for the servant who waited on me. — Without breaking it? — Without breaking it. — Ah! my dear Abbé, one never eats an egg without breaking the shell afterwards.” (Notes on the poem La Gastronomie.) Grimod de la Reynière (Almanach des gourmands, year 3, p. 349–350) preoccupied himself with this usage, and assures that he pondered its motive deeply deeply. Pliny himself, who first related it, did not appear to know. “Anyway, said the famous gourmand, there is no downside to subjecting oneself to this usage.”
Grimod de la Reynière published his Almanach between 1803 and 1810. He discusses the same anecdote (citing Berchoux as his source). Here is the exact quote (my translation) about the eggs:
After eating a fresh egg, it is not permissible to send back its shell full; one must break the shell on one's plate before changing it.
Think as we might about this strange law, we were unable to guess its raison d'être. It is undoubtedly caused by facts that we are ignorant of. Anyway there is no downside to subjecting oneself to this usage.
The text from Pliny is from The Natural History book 28 chapter 4 (and not ch. 4).
There is no one, too, who does not dread being spell-bound by means of evil imprecations; and hence the practice, after eating eggs or snails, of immediately breaking the shells, or piercing them with the spoon.
Signs, Omens and Superstitions by “Astra Cielo” (1918) states that
Eggshells must be broken and not left to lie about the house, or they may be used by witches as boats.
I don't know if this is the same superstition that Pliny was refering to.