How to generate $3 \times 3$ integer matrices with integer eigenvalues?
How about the following:
- Pick a diagonal matrix $\Lambda$ with integer diagonal entries. The eigenvalues will be multiples of these.
- Pick a matrix $V$ with integer entries so that $V$ is invertible, $\det(V)\neq 0$.
- Form $A=\det(V)V\Lambda V^{-1}$.
$A$ is guaranteed to have integer entries. One formula for the inverse of $V$ is $V^{-1}=\frac{1}{\det(V)}\mathrm{adj}(V)$ where $\mathrm{adj}(V)$ is the adjugate of $V$. The adjugate has integer entries since the entries are determinants of minors of $V$.
The eigenvalues of $A$ are the diagonal entries of $\Lambda$ scaled by $\det(V)$. Note that you can always pick $V$ to have a unit determinant. For example, choose $V$ as upper Hessenberg with 1's on the first subdiagonal. Then the upper right corner entry can be used to control the determinant and ensure it is $\pm 1$ (or any other desired value).
As an example, take $\Lambda=\left[\begin{array}{ccc}17&0&0\\0&-2&0\\0&0&3\end{array}\right]$ and $V=\left[\begin{array}{ccc}2&3&x\\1&-1&5\\0&1&1\end{array}\right]$. Then $\det(V)=-15+x$ so we can choose $x=16$ to get $\det(V)=1$. The result is $A=\left[\begin{array}{ccc}-150&334&778\\-89&195&464\\5&-10&-27\end{array}\right]$.