In phonology, we refer to ん as a phoneme. A phoneme is a mental representation of a sound, which native speakers will usually receive as the same sound, and we usually represent that with slashes, like this: /ɴ/. That’s the most common representation for the ん sound in phonology, but I’m going to continue to write it as ん for the purposes of this little tutorial. ん has a few different pronunciations based on the sound that follows it. We represent these more concrete sounds with square brackets: [n], ][ɴ], [ŋ], [m], etc. These different pronunciations are called allophones. ん is one sound as far as the Japanese language is concerned, but five sounds physically.
If this sounds bizarre and foreign, consider the /t/ sound in English. Think about the /t/ sound in the following words:
If you speak the same dialect of English as I do, those will all have different pronunciations. The /t/ in “toy” has a little puff of air after it, while the /t/ in “steam” has none. /tr/ blends into a “chr” sound for me, and I imagine for most English speakers. The /t/ in “water” is a quick flap of the tongue behind the teeth, and the /t/ in “robot” is actually made by cutting off the air supply at the vocal folds. There are many similar processes in English, and probably in every language.
Back to Japanese. When Japanese people use an ん sound, they actually produce it in a few different ways. Phonetically, we’d say that the ん sound agrees in place of articulation with the sound that follows it. That means that you make the ん sound in the same parts of your mouth (lips, tongue, teeth) as the sound that comes after it.
Let’s start at the lips and work our way back. Before a bilabial stop, like [p, b, m], the ん sound is made with your lips. That means that you get an [m] sound, which is the same as the first consonant in the English words “make mine Marvel”.
Next up is the alveolar ridge, which is the area right behind your teeth. We make the sounds [t, d, s, z] there. That means that ん becomes a [n] sound, the same as the one that begins words like “Narnia” and “navel-gazing”.
- ポンド [pondo]
Further back in the mouth, we have the velars, like [k, g], which are made on your soft palate, or velum. That’s the squishy bit on the top of your mouth, near the back. ん before these sounds becomes a [ŋ] sound, like in the English words “English”, “crank”, and “bowling”.
- レンガ [reŋga]
Next, let’s look at vowels, which are made without touching the tongue or lips. To make ん before a vowel, nasalize the preceding vowel. This one was the trickiest sound for me to acquire for sure, because we don’t differentiate nasal vowels in English. Try saying the words “win” and “wit”, and notice how the /ɪ/ sound changes. Now try “boon” and “boot”. English speakers naturally nasalize vowels before a nasal consonant, so you need to be able to do that at will in Japanese (French as well, for that matter). Japanese speakers also seem to use this before the [ɸu] sound, ふ.
- インフルエンザ [ĩɸu̥ɾuenza]
Finally, there’s the ん sound at the end of a sentence. With nothing coming after it, how do you know which one to use? Phonological literature usually suggests the [ɴ] sound, which is made by touching the back of the tongue to the uvula. In practice, however, Japanese people will use [ŋ, n, ɴ] or [m] for the final ん sound. I’d say, default to [ɴ], but keep your ears open and use whichever is most comfortable.
- 一番（いちばん）[itɕibaɴ]/ [itɕibam]/ [itɕibaŋ]/[itɕiban]
TL;DR: ん generally agrees in place of articulation with the sound that comes after it. By “place of articulation”, I mean the location of your tongue and/or lips when you make the sound.
Good luck, have fun!