Dignity is honorableness, a quality of the person being elevated. Respect is a viewpoint, a quality of the person doing the elevating.
In your example context, there is considerable overlap of connotation, and one could be used in place of the other. In other contexts, it would be hard to do so. For example, we can refer to the dignity (honorableness) of an action, but can’t meaningfully substitute respect. And we can refer to things differing in some respect (from some viewpoint), but can’t meaningfully substitute dignity.
Dignity identifies a worthy, high, and honorable condition. When person A treats person B with dignity, it means person A acknowledges person B’s dignity (worth or value). This is also seen in the verb dignify: if I say “I refuse to dignify that with an answer”, I mean I refuse to treat the question as worth answering: it’s not me, but the question itself that lacks dignity.¹
Respect identifies the act of paying attention or proper consideration, and by extension the act of viewing someone as worthy of such consideration. When person A treats person B with respect, it means person A takes proper notice of person B, according person B due care and honor. This is also seen in the verb to respect: if I say “I refuse to respect that decision”, I mean I refuse to treat the decision as worthy of respect: it’s me, not the decision, that lacks respect.²
It is helpful to look at the etymology of these words, because their meanings reflect their history. Dignity comes from the Latin noun dignus, “worth”, and is related to other valuing words such as dignitary, dainty, deign, disdain, and indignation.³ Respect comes from the Latin verb respicere, literally “look back at”, and is related to other viewing words such as spectator, spectacles, and inspect.⁴