In Latin, "gn" was pronounced [ŋn]. Latin velar-coronal digraphs like this (and also cl, cr, ct, gd, gl, gr, and x) underwent a palatal mutation to varying degrees in most Italo-Western Romance languages, and in most of those languages that preserve the gn spelling (such as Italian and French), it is pronounced as a palatal nasal [ɲ]. This was not the case in Dalmatian and the Eastern Romance languages where a different mutation changed the velar component to a labial consonant, changing the spelling in those languages to mn.
In English, the digraph is simply pronounced /n/ initially and finally(i.e. gnome, gnu, benign, sign). When it appears between two syllables, the /g/ is pronounced within the first syllable, while the /n/ is pronounced in the second syllable (i.e. signal).
In Norwegian, the digraph is pronounced [ŋn] in monosyllabic words like, "agn" and between two syllables, "tegne". The same spelling represents the same sound in Swedish too. Initially it is simply [gn], eg. Swedish gnista ['gnɪsta]]