Can D and G ocarinas play together?

Yes, if you are willing to experiment and write harmony parts, or play by ear. Try playing the tune on a D ocarina, and improvise harmonies with a G ocarina. The sound of two differently pitched ocarinas playing together can be wonderful. Ocarina charts are suitable for both D and G ocarinas, so groups of G ocarinas can play well together at their own pitch using the books. Masquerade Ocarinas play arrangements for D and G ocarinas. Videos of these can be seen on this site, and on YouTube.