according to sjp.pwn.pl Dziękować is loan word from "staro-wysoko-niemieckiego"(literally old-high-german) danken, denke (now Dank)
It was religious (Deo gratias facere), and came to Poland form Czech with Christianity, They still exist in Czech and Slovakian and though Polish went to Ukrainian and Russian.
I don't think one can write it in Cyryllic, there is no corresponding sound. ę is palatalized e, and I guess it sounds a bit like an additional N - which makes some less educated natives sometimes write it 'dzienki', which is clearly an orthographic mistake. It is closest in pronunciation to 'eu', for example in Spanish pronunciation of "Europa".
If it's at the end of the word, it usually is less clear and a bit more like simple e, for some people even totally like simple e.
The letter 'ę' is a nasalized version of 'e'. Tip to pronounce the letter is to pronounce the syllable 'en' in the word 'sense', but don't let your tongue touch the roof of your mouth. Modern Slavic languages that use the Cyrillic alphabet do not have that sound, although that letter existed in Old Church Slavonic as the letter 'ѧ'.
Is there an "n" sound before the "k"?
An "ng" sound /ŋ/ as in "sing", not an "n" sound /n/ as in "sin".
Is that what the accent on the "e" does?
The ̨ mark (ogonek) originally marked nasalation of the vowel -- ę is /ɛ̃/ like French in, ą is /ɔ̃/ like French on.
But before a stop p t k b d g or affricate cz ć dż dź, the vowel is usually not pronounced nasalised -- instead, a homorganic nasal sound comes between the vowel and the consonant -- so nasal vowel before p b turns into [m] (e.g. dąb "oak" sounds as if written domp), nasal vowel before t d cz dż turns into [n] (e.g. kąt "angle" sounds as if written kont), nasal vowel before k g turns into [ŋ] (e.g. dzięki sounds as if written dźenki), nasal vowel before ć dź turns into [ɲ] (e.g. pięć "five" sounds as if written pieńć).
And at the end of a word, the nasalisation may simply get dropped entirely, e.g. proszę "please; I ask" sounds as if written prosze.
Sanskrit is indeed older than old high German, but most of the languages of the world did NOT originate from sanskrit (the hindi languages do, but no European language does). Sanskrit and other Indo-European languages share the ancestor though, proto-Indo-European, so the 'dan' in 'danke' and 'dhaan' in 'dhaanyavaad' could be cognates if they both originally meant 'to give'. It would find it hard to believe that polish would have borrowed a sanskrit word though.