Negative modulo: why is $-3$ mod $12$ equal to $9$? I know that in general, we can represent a number $x$ as follows:

$x = qn + r$

where $r$ is the remainder, $n$ is the divisor, and $q$ is the quotient.

But suppose we try to calculate $-3 \div12$. An answer elsewhere on Math StackExchange suggests that the answer is:

$-3 = -1 \times12+9$

In other words, that $-3 \mod 12 = 9$.

But can't we represent this as:

$-3 = -2 \times 12 + 21$

And get a different answer?
It's true that $-3\equiv 21 \bmod 12$. And also that $-3\equiv 117 \bmod 12$, and and of course $-3\equiv 9 \bmod 12.$ All of these numbers are in the same congruence or residue class. Typically the smallest non-negative value is used to represent the class.
I think you’re overcomplicating it. It simply boils down to this:

$$b\equiv c\pmod m \iff \frac{b-c}{m}\in\Bbb Z$$

where $\Bbb Z$ contains negatives as well as positives.

Since $$\frac{-3-9}{12}=-1$$ we say $-3\equiv 9\pmod {12}$ or alternatively $-3\bmod 12 =9$.