Pronunciation of double G: soft "gg" versus hard "gg"
Vegged/vegging (forms of the verb to veg, an abbreviation of vegetate), veggies (abbreviation of vegetables), and aggerate/-ates/-ated/-ating/-ation.
The rule you mention might be useful as a rule of thumb, but it seems to me that it is basically a coincidence brought about by the confluence of several factors.
Generally, soft <g> only occurs before a front vowel letter
With very few exceptions, <g> can only be "soft" /dʒ/ when it comes before one of the letters <e>, <i> or <y>. (This is parallel to the rule for pronouncing <c> as "soft" /s/ vs. "hard" /k/.) You don't need any other rule to explain why <g> is hard in agglomerate, aggregate, aggressive, niggard.
In native English words, double "soft g" /dʒ/ is spelled <dg(e)>
In normal English words like bridge or ledge that have "short" vowels and that end in /dʒ/, the general pattern is to use <dge> to spell the final sound. This is comparable to the use of the trigraph <tch> to represent the sound /tʃ/ after "short" vowels. These two patterns mean that there are no native English words that are spelled with <cch> for /tʃ/ or with <gge> for /dʒ/.
In general, consonant-doubling suffixes don't soften hard <g>
At the end of a word, <g> (outside of the digraph <ng>) is "hard" /g/ as a rule, and this pronunciation is retained before a number of extremely common vowel-initial suffixes that cause a preceding consonant letter to be written double in certain circumstances (generally, when the consonant is directly preceded by a stressed short vowel). Among these are the suffix -y/-ie, the suffix -ing, the suffix -ed, the suffix -er and the suffix -est.
So words like foggy, doggie, wagging, digger, biggest all have hard /g/, but it doesn't make much sense to say that this is because the letter is doubled. Rather, the hard /g/ is because fog, dog, wag, dig, big (all spelled with a single <g>) are pronounced with hard /g/.
And on the other hand, the examples I gave above, vegged and veggies, have a double <gg> (because of the preceding "short" vowel sound) and are pronounced with a soft /dʒ/ because they are derived from the words vegetate and vegetable that are pronounced with soft /dʒ/.
The two "exceptions" regularly follow a rule for Latinate words
There happen to be very few English words from Latin that are spelled with double <gg> before <e>, <i> or <y>. So, the pronunciation of <gg> in the two words exaggerate and suggest does seem like an "exception" when compared to the pronunciation of most words spelled with <gg> in English: words ending in the suffixes that I identified in the previous section.
However, there is no particular reason to expect the "velar softening" rule, which says that says that <g> is pronounced as /dʒ/ before <e> in Latinate words, to be inapplicable in this context. Comparison with the behavior of double <cc> actually suggests that velar softening should apply to the second <g> in exaggerate and suggest: the second <c> in words like succeed and accept is pronounced as /s/.
The "velar softening" rule does have a few miscellaneous exceptions, such as gibbous, and it seems that at one point some English speakers pronounced exaggerate with /g/. The entry for exaggerate in Walker's Critical Pronunciation Dictionary of 1791 says
This word is sometimes heard with the double g hard, as in dagger; but every one who has a scrap of Latin knows, that exaggerate comes from exaggero, and that all words from that language have the g soft before e and i: the third syllable, therefore, must have the e soft. But it will be said, that, according to the laws of pronunciation, the first g ought to be hard, as the first c is in flaccid, siccity, &c. To which it may be answered, that, strictly speaking, it ought to be so; but polite usage has so fixed the first, as well as the last g in the soft sound, that none but a confirmed pedant would have the boldness to pronounce it otherwise.
Walker's "sometimes heard" suggests that pronouncing exaggerate with /g/ was rare even in his time, and I have never heard it in my lifetime.
It makes sense to extend the pronunciation pattern of exaggerate to analogous Latinate words like aggerate (which the OED lists as being pronounced /ˈædʒəreɪt/ with a soft g), aggeneration, circumaggerate, aggestus.
Remaining cases
That leaves dagger and doggerel unexplained from the original list. There are also the additional words agger, chigger, nigger, trigger, and juggernaut.
It seems somewhat significant to me that most of these end in -er (although exaggerate does also contain the written sequence <er>). In a way, they seem similar to words like digger that have a suffix.
Agger is from Latin, and actually, it seems to be generally pronounced with /dʒ/ (although the OED lists a variant pronunciation with /g/).
-
In dagger, the er may actually be the -er suffix historically; Oxford Learner's Dictionaries say
late Middle English: perhaps from obsolete dag ‘pierce, stab’, influenced by Old French dague ‘long dagger’.
-
In doggerel, the first part appears to be derived from the English word dog, which has a hard /g/, so we wouldn't expect the g to be softened. Oxford Learner's Dictionaries say
late Middle English (as an adjective describing such verse): apparently from dog (used contemptuously, as in dog Latin, a debased form of Latin) + -rel.
Nigger and chigger are phonetic variations of words that originally had hard /g/. Trigger seems to ultimately come from Dutch. Juggernaut is from Sanskrit Jagannātha.
Exceptions from loanwords that follow other languages' spelling systems
As Peter Shor points out, in loanwords from Italian <gg> is regularly soft before <e> or <i>, again ignoring this supposed "double <gg> = hard /g/" rule and instead following the front-vowel-letter rule that is usual in words that are derived from Latin.
Hard/Soft G is more variable at the beginning of words, but G (or double G) is always hard in the middle of these longer words if it is also so in the root. "Singer" could be hard or soft, depending on if you mean "one who sings" or "one who singes."
The only common exceptions I can find are the words that use the word "get" like "forgetful" and a long list of words with GER at the end of their root: "tiger" "anger" etc...
"Exaggerate" is actually an exception to the exception because it used to be pronounced with the hard G (one of the GER words mentioned above) but the final T has actually pulled our pronunciation of the G up to the teeth and turned it into a J. Perhaps we should now spell it with a DG.
In conclusion, a medial GI/GE is hard only if the root word is hard. And the root is hard only if it ends in G or GER or is a variant of "get".