For a spin 1 system l = 1 and m = -1 , 0 , 1. For the operator S z {\displaystyle S_{z}} we have
S z | l , m ⟩ {\displaystyle S_{z}|l,m\rangle } ⇒ {\displaystyle \Rightarrow } ⟨ l , n | S z | l , m ⟩ = m ℏ ⟨ l , n | l , m ⟩ {\displaystyle \langle l,n|S_{z}|l,m\rangle =m\hbar \langle l,n|l,m\rangle } ⇒ ( S z ) n m = m ℏ δ n m {\displaystyle \Rightarrow (S_{z})_{nm}=m\hbar \delta _{nm}}
So
S z = ℏ ( 1 0 0 0 0 0 0 0 − 1 ) {\displaystyle S_{z}=\hbar {\begin{pmatrix}1&0&0\\0&0&0\\0&0&-1\\\end{pmatrix}}} ⇒ {\displaystyle \Rightarrow } S z 2 = ℏ 2 ( 1 0 0 0 0 0 0 0 1 ) {\displaystyle S_{z}^{2}={\hbar }^{2}{\begin{pmatrix}1&0&0\\0&0&0\\0&0&1\\\end{pmatrix}}}