The punchline: given $J$ and $T$, a solution $D$ exists if and only if $p \geq \operatorname{rank}(T)$, where $p$ is the number of $+1$ entries in the signature matrix $J$.
It follows that a solution will exist for all possible matrices $T$ if and only if $p \geq m$.
We'll focus on the case that $J \neq \pm I$. Without loss of generality, we can suppose that $J$ has the form
$$
J = \pmatrix{I_p & 0\\0 & -I_q}
$$
for positive integers $p,q$. Partition $D$ into the form
$$
D = \pmatrix{D_1\\ D_2},
$$
where $D_1$ is $p \times m$ and $D_2$ is $q \times m$. We find that
$$
D'JD = D_1'D_1 - D_2'D_2.
$$
The matrix $T'T$ is necessarily positive semidefinite, so in order to have $D'JD = T'T$ it must be the case that $D'JD$ is positive semidefinite. Under this assumption, we note that $D'JD \preceq D_1'D_1$ (where $\preceq$ denotes the Loewner order), which means that the rank of $D'JD$ is less than or equal to the rank of $D_1'D_1$. The rank of $D_1'D_1$ is necessarily equal to the rank of $D_1$, which is at most equal to $\min\{p,m\}$.
This leads us to the following conclusion: if there is a solution to the equation $D'JD = T'T$, then it must be the case that
$$
p \geq \operatorname{\min}\{p,m\} \geq \operatorname{rank}(T'T) = \operatorname{rank}(T).
$$
That is, it must be the case that $p \geq \operatorname{rank}(T)$.
The converse holds as well. Suppose that $p \geq \operatorname{rank}(T)$. It follows that $T$ has a "thin" $QR$ decomposition where $Q$ is $m \times p$ with orthonormal columns and $R$ is $p \times m$. It follows that
$$
T'T = (QR)'(QR) = R'Q'QR = R'R.
$$
If we take $D_1 = R$ and $D_2 = 0$, then we find that $D'JD = R'R = T'T$, which was what we wanted.