3D vs 3d vs 3-d vs 3-dimensional
I am searching for an answer to the same question. I wouldn't use 3d, 3-d, or 3-dimensional because I have never seen them. Longman dictionary says three-D or 3-D (Longman), but Oxford also says 3D (Oxford). So I think 3D or 3-D are accepted.
According to this Ngram, both 3d and 3D are acceptable to use. Furthermore, different dictionaries show a different form of abbreviation for "three-dimensional". Some are 3-D, some 3D, some 3d, and so on.
From this I would conclude that none of these are incorrect to use. 3-dimensional is not something that is recommended though, as shown from the results.
Ngram also shows that "three-dimensional" is used just as much as 3D or 3d. Perhaps that is the best option to consider using in formal writing, since formality doesn't have fondness for abbreviations.