We assume $n=2$ and we consider $A,B\in SL_2(\mathbb{R})$ s.t. $A,B$ are not simultaneously triangularizable over $\mathbb{C}$ (that is $\det(AB-BA)\not= 0$). Let $C,D\in SL_2(\mathbb{Z})$ s.t. $(A,B)$ and $(C,D)$ are in the same class of simultaneous similarity. By a result due to Friedland, such a class modulo $GL_n(\mathbb{C})$ depends only on the values of $tr(A),tr(A^2),tr(B),tr(B^2),tr(AB)$. Here $\det(A)=\det(B)=1$; then, as wrote Andreas, it suffices to know $tr(A),tr(B),tr(AB)$.

Thus a necessary condition for the existence of $(C,D)$ is

$(*)$ $tr(A),tr(B),tr(AB)\in\mathbb{Z}$.

Conversely, under the above conditions $(*)$, assume that there are $C,D\in SL_2(\mathbb{Z})$ satisfying $tr(A)=tr(C),tr(B)=tr(D),tr(AB)=tr(CD)$. There is $P\in GL_2(\mathbb{C})$ s.t. $P^{-1}AP,P^{-1}BP\in SL_2(\mathbb{Z})$; clearly, we can choose $P\in GL_2(\mathbb{R})$ and even $P$ s.t. $\det(P)=\pm 1$. If $P=\begin{pmatrix}a&b\\c&d\end{pmatrix}$ then let $Q=\begin{pmatrix}-a&b\\-c&d\end{pmatrix}$; then $\det(Q)=-\det(P)$ and $Q^{-1}AQ,Q^{-1}BQ\in SL_2(\mathbb{Z})$. Finally we can choose $P\in SL_2(\mathbb{R})$.

The question is whether $C, D$ always exist.

Let $a,b,c\in\mathbb{Z}$. We can always find $A,B\in SL_2(\mathbb{C})$ satisfying

$(1)$ $tr(A)=a,tr(B)=b,tr(AB)=c$, but it's false in $SL_2(\mathbb{Z})$.

EDIT 1. $\textbf{Remark}$. Let $C,D\in SL_2(\mathbb{Z})$ satisfying $(1)$; if we want to simplify the form of $C,D$ (at least that of $C$) to simplify the required sufficient condition concerning a, b, c, then we must go through its conjugacy class wrt. $GL_2(\mathbb{Z})$. Unfortunately, to a fixed trace, can correspond several such conjugacy classes.

For example, to $tr(C)=-1$ corresponds a unique class, that of $\begin{pmatrix}0&-1\\1&-1\end{pmatrix}$; yet, when $tr(C)=12$, there are at least $2$ conjugacy classes, that of $\begin{pmatrix}0&-1\\1&12\end{pmatrix}$ and $\begin{pmatrix}7&2\\17&5\end{pmatrix}$.

Note that, in the previous examples, the characteristic polynomial is irreducible. Let $f\in\mathbb{Z}[x]$ be monic irreducible of degree $2$. A result due to Latimer, Mac Duffee says

$\textbf{Theorem}$. The conjugacy classes of matrices $C\in M_2(\mathbb{Z})$ with $\chi_C=f$ are in bijection with the $\mathbb{Z}[u]$-ideal classes in $\mathbb{Q}(u)$ where $f(u)=0$.

$\textbf{Conclusion}$. When $f$ is irreducible, we can find the classes with the help of the software Magma.

When $f$ is reducible, $C$ is similar, over $\mathbb{Z}$, to a matrix in the form $\begin{pmatrix}\epsilon&b\\0&\epsilon\end{pmatrix}$ where $\epsilon=\pm 1,b\not= 0.$

Let $U=\{(a,b,c)\in\mathbb{Z}^3;$ there are $C,D\in SL_2(\mathbb{Z})$ not simultaneously triangularizable and s.t. $tr(C)=a,tr(D)=b,tr(CD)=c\}$.

Since the number of representatives for $C$ depends on $a$, I think that there are no algebraic representation of the fact that $(a,b,c)\in U$; we have to work on explicit values of a, b, c.
$\square$

For example, if we consider the standard class associated to $a$, then the required condition is as follows

$(C,D)$ are simult. similar to $C=\begin{pmatrix}0&-1\\1&a\end{pmatrix},D=\begin{pmatrix}p&q\\r&b-p\end{pmatrix}$ and the condition can be easily written

$p(b-p)-qr=1,-r+q+a(b-p)=c$.

It is a system of $2$ equations in the unknowns $p,q$ (considering $r$ as a parameter). It is not difficult to prove (discuss according to parity of $ar-b$) that a necessary and sufficient condition for the existence of integer solutions is

There is $r\in\mathbb{Z}$ s.t. $(ar-b)^2-4(-abr+cr+r^2+1)$ is a square, that is

$(2)$ there is $r\in\mathbb{Z}$ s.t. $(a^2-4)r^2+(2ab-4c)r+b^2-4$ is a square.

Note that the coefficients of $r^2,r,1$ are independent.

Of course, if we consider the standard class of $D$ (instead of that of C), then the condition becomes

$(2')$ there is $r\in\mathbb{Z}$ s.t. $(b^2-4)r^2+(2ab-4c)r+a^2-4$ is a square.

There are instances s.t. the solutions in $a,b,c,$ of $(2)$ and $(2')$ are not the same.

EDIT 2. $\textbf{The case when $A,B$ are simultaneously triangularizable}$ and where $tr(A)=a,tr(B)=b,tr(AB)=c$ are integers. Then, necessarily, $a,b,c$ are linked by a unique relation $a^2+b^2+c^2-abc-4=0$ (according to the @user44191 's comment below).

The above relation can be realized by integers iff $(b^2-4)(c^2-4)$ is a square. In the sequel, we suppose that $a,b,c$ satisfy the above two conditions.

CASE 1. $A$ or $B$ (for example $A$) has distinct eigenvalues $p,q$. To a fixed $a,b,c$ are associated $3$ possible similarity classes, over $\mathbb{C}$, for the couple $(A,B)$

$[diag(p,q),\begin{pmatrix}r&1\\0&s\end{pmatrix}],[diag(p,q),\begin{pmatrix}r&0\\1&s\end{pmatrix}],[diag(p,q),\begin{pmatrix}r&0\\0&s\end{pmatrix}]$.

In a second step, one calculates the similarity classes associated to $tr(A)$ over $\mathbb{Z}$ and we seek the conditions about $a,b,c$ (for the $3$ classes) as in the detailed example (the case of the standard class) in the first part of the post.

CASE 2. $A$ and $B$ have double eigenvalues $\pm 1$.

2.1. $A$ or $B$ (for example $A$) is equal to $\pm I_2$; then the condition $b\in\mathbb{Z}$ suffices.

2.2. $A,B$ is similar over $\mathbb{C}$ to $\pm\begin{pmatrix}1&1\\0&1\end{pmatrix},\pm\begin{pmatrix}1&u\\0&1\end{pmatrix}$ where $u\not= 0$.

Proceed over $\mathbb{Z}$ as in the first part of the post.