Let $A = \mathcal M_n(k)$ be the full matrix algebra over a field $k$. If $\phi:A\to A$ is a nonzero endomorphism of $A$ as a Lie algebra, must it automatically be an endomorphism of $A$ as a unital $k$-algebra?
If not, what would be necessary conditions?
EDIT As TorstenSchoeneberg pointed out in the comments, a necessary condition is that $\phi$ is the identity on $k$. Could this also be a sufficient condition?
Short answer: This is true (at least in characteristic zero) if and only if $\phi$ is given by conjugation with some matrix.
Let $k$ be a field of characteristic $0$, and let's call $\mathfrak{gl}_n(k)$ the Lie algebra, but $M_n(k)$ the associative unital algebra of $n \times n$-matrices over $k$ (i.e. it's the same set and even $k$-vector space, but the multiplicative structure is different.) Let $\phi$ be an endomorphism of $\mathfrak{gl}_n(k)$.
With $\mathfrak{sl}_n(k)$ denoting those matrices in $\mathfrak{gl}_n(k)$ of trace $0$, observe that we have a decomposition
$$\mathfrak{gl}_n(k) \simeq \mathfrak{sl}_n(k) \oplus k \cdot Id$$ given by $x \mapsto (x - \frac1n tr(x), \frac1n tr(x))$. This is a decomposition of $k$-vector spaces and even of Lie algebras, but (for $n \ge 2$) not of associative algebras.
Because $\mathfrak{sl}_n(k)$ is the derived Lie algebra, and $k \cdot Id$ is the centre of $\mathfrak{gl}_n(k)$, both spaces are actually invariant under $\phi$, and it suffices to investigate the restrictions $\phi_{\mathfrak{sl}_n(k)}$ and $\phi_{k\cdot Id}$. As discussed in the comments, $\phi_{k\cdot Id}$ can be any scalar multiplication, but for $\phi$ to be an endomorphism of $M_n(k)$, it necessarily has to be the identity, so let's assume that from now on.
Now since $\mathfrak{sl}_n(k)$ is simple, we either have $\phi_{\mathfrak{sl}_n(k)} = 0$, or $\phi_{\mathfrak{sl}_n(k)}$ is an automorphism.
If $\phi_{\mathfrak{sl}_n(k)}$ is an automorphism, it is either an inner or an outer one.
If it is an inner one, by definition it is given by conjugation with some $g \in GL_n(k)$, and hence obviously is also an automorphism of $M_n(k)$ given by $\phi(x) = gxg^{-1}$.
If $\phi_{\mathfrak{sl}_n(k)}$ is an outer automorphism, we have $n \ge 3$ and up to conjugation like above we have $\phi_{\mathfrak{sl}_n(k)}$ being the negative of the transpose: $\phi_{\mathfrak{sl}_n(k)}(x) = -x^t$. But e.g. $E_{12}\cdot E_{23} = E_{13}$ whereas $-E_{21}\cdot -E_{31} = 0$, so this has no chance to be multiplicative even on the traceless matrices.