Yes. Let $A_n = \mathrm{diag}\left(\frac{1}{2}(1 + \sqrt{5}), \dots, \frac{1}{2}(1 + \sqrt{5})\right)$ and $B_n = \mathrm{diag}(1, \dots, 1).$ This example will work for any $n$.
Edit: Now, for a general solution in the noncommutative case, combine my commutative general solution with Robert Israel's $2 \times 2$ noncommutative solution, taking the block diagonal matrices $\tilde{A}_n = \begin{pmatrix} A_{n-2} & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{pmatrix}$ and $\tilde{B}_n = \begin{pmatrix} B_{n-2} & 0 & 0 \\ 0 & -\frac{1}{2} & 1 \\ 0 & -\frac{7}{2} & 3 \end{pmatrix}.$