I've noticed that it's not uncommon for Dungeons and Dragons to be shortened to "DnD."
Is this officially correct? I know official sources often shorten it to "D&D," but have any official sources spelt it as "DnD?"
The official abbreviation is D&D; DnD is a fan invention. It has gained currency today with the help of the Internet, where it's both easier to type and less likely to be mangled by badly-designed website software.
(In any case, the conventional rendition of the verbally-abbreviated and is ’n’, so an official spelling of the verbal "Dee uhn dee" would have more likely originally been D’n’D anyway, if it had been chosen, not DnD.)
Incidentally, "Dungeons and Dragons" is also inaccurate, as the title has always used an ampersand, as in Dungeons & Dragons.
The only places where the n appears officially today are where an ampersand can't or shouldn't be used — such as in web site domain names (where ampersands are forbidden for technical reasons) and filenames that have to be cross-platform (where the ampersand is an "unsafe character"). Hence we have dndclassics.com instead of d&dclassics.com, and dnd.wizards.com, D&D's home. Anywhere that ampersands are not technically impossible or inadvisable to use, the official abbreviation is always D&D.
There is a term for writing down a word based on how it sounds, a "vocable," when you dig into phonology. If you go back before the Endless September, that usage was conversational rather than written or typed or found on line.
When you run "D and D" together in spoken form, which is short for "Dungeons and Dragons" (which abbreviation goes back to the 70's when the game emerged) it sounds like "D-n-D" (or dee uhn dee). I remember our group referring to it in that short hand in high school (mid 70's) and hearing the same in college in the groups I played in.
DnD is the typed expression of that abbreviation. As noted in @SevenSidedDie's answer, the prohibitions on use of ampersands (&'s) in some computer usage has abetted the spread of that abbreviation to the point that is has become short hand ... even on the web site for the company that now owns the game. Because Wizards of the Coast includes it in their web sites name for that product (dnd.wizards.com) you can argue that dnd is an official abbreviation for the game.
While @SevenSidedDie's answer is not in error, the world, this word/abbreviation and the game existed before the internet did.
In simplest terms:
Wizards makes use of the DND version on filenames and URLS, therefore it is clearly acceptable to them to use it. Examples include the URLs for the D&D website (dnd.wizards.com) and the D&D AL website (dndadventurersleague.org), and several filenames over the last 3 years, such as DnDAdvLgLogsheet.pdf (currently available from the D&D AL OOTA downloads page.
This is not the only mode of shortening, though. Several filenames instead start with DD, especially adventures for adventurer's league, such as DDEOutoftheAbyss.pdf, and others lack a D&D prefix at all, such as ALPGv3.pdf.