Both /m/ and /ŋ/ occur as syllabic consonants as a result of assimilation or elision. There are not many things to be said about syllabic /m/ and /ŋ/ so few examples are all we need.
A good example to start with is the word "happen". This is a fascinating word if you want to observe different pronunciations. It can be pronounced in many different ways such as /ˈhæp’ən/, /ˈhæpn/, /ˈhæp.n/ (with the syllabic /n/), /ˈhæp.m/ (with the syllabic /m/) etc.
By far the most common pronunciation is the first one but the third one (with the syllabic /n/) is very common in British English. The pronunciation with the syllabic /m/ is equally accepted but not very common.
Another good example is the word "uppermost" which can be pronounced like /ˈʌp’ərˌmoʊst/, /ˈʌp.ə.məʊst/, /ˈʌpər.məst/, /ˈʌp.maʊst/ etc.
One example that comes through my mind where syllabic /n/ or /ən/ could be substituted for /ŋ/ is the word "thicken". It can be pronounced /ˈθɪk’ən/, /ˈθɪk.n/ or /ˈθɪk.ŋ/.