You can cast the spell with any spell slot available to you.
This is a multiclassing issue, so the following questions arise.
Can you prepare the spell/Do you know the spell?
Yes. As Armor of Agathys is a 1st level Warlock spell, and you have 2 levels in the Warlock class, it is clear that you have this spell.
Spells Known and Prepared. You determine what spells you know and can
prepare for each class individually, as if you were a single-classed
member of that class.
Do you have the spell slot?
Yes. In your example, at Sorcerer level 17 you would get your 9th level spell slot.
You determine your available spell slots by adding together all your
levels in the bard, cleric, druid, sorcerer, and wizard classes, half
your levels (rounded down) in the paladin and ranger classes, and a
third of your fighter or rogue levels (rounded down) if you have the
Eldritch Knight or the Arcane Trickster feature. Use this total to
determine your spell slots by consulting the Multiclass Spellcaster
Can spells gained from Pact Magic be cast in other spell slots?
Yes. It is explicitly stated that this is possible.
you can use the spell slots you gain from the Pact Magic feature to
cast spells you know or have prepared from classes with the
Spellcasting class feature, and you can use the spell slots you gain
from the Spellcasting class feature to cast warlock spells you know.