Wiktionary says the pronunciation of modern Portuguese pão is [pɐ̃ʊ̯̃] in IPA. Modern Japanese has [p] but not [ɐ̃]. The vowel closest to [ɐ] is [a], and to get the nasalization of [ɐ̃], the following consonant needs to be [ɴ], giving "pan" [pãɴ]. As a bonus, [ʊ̯̃] is a back nasal vowel and [ɴ] is a back nasal consonant. So modern Japanese "pan" is a good match for modern Portuguese pão.
To support your theory, you'd need to look at a language where borrowings with nasal vowels and syllable-final nasal consonants can reliably be distingished from each other, i.e. not Japanese.
Not quite! This is a peculiarity of Japanese transcription: the moraic nasal [0] is often transcribed as /ɴ/ or /N/ in phonemic representation, while its phonetic realisation varies between [m~n~ɲ~ŋ]; it is true uvular [ɴ] only utterance-finally, but apparently even that is controversial.
I wrote [ɴ] instead of /ɴ/ for a reason. It's true that the phoneme /ɴ/ has various realizations (including as no consonant at all, only nasalizing the preceding vowel), but when considering "pan" in isolation, the /ɴ/ is utterance-final and has the commonly accepted realization [ɴ].
To support your theory, you'd need to look at a language where borrowings with nasal vowels and syllable-final nasal consonants can reliably be distingished from each other, i.e. not Japanese.