You can find an explicit counterexample in the Riemannian Schwarzschild solution.
Let $(z,r,\omega) \in \mathbb{R} \times (1,\infty) \times \mathbb{S}^2$, denote by $h$ the standard sphere metric. Consider the following Riemannian metric
$$ ds^2 = (1- r^{-1})~dz^2 + (1-r^{-1})^{-1} ~dr^2 + r^2 h $$
One can explicitly compute that this metric is Ricci-flat using:
- The metric is a warped product of $\mathbb{R}\times (1,\infty)$ against the sphere,
- Exercise 5.5 from O'Neill's Semi-Riemannian Geometry
- Standard formulae for the Gauss curvature of a diagonal metric in two dimensions.
As a warped product, fixing any $\omega\in \mathbb{S}^2$, the submanifold $\mathbb{R}\times (1,\infty) \times \{\omega\}$ is totally geodesic, but it has non-vanishing Gauss curvature $K = \frac{1}{r^3}$ and so is not Ricci flat.
(I think you also have a co-dimension one example if you look at a $z$-level set, which is totally geodesic due to the reflection symmetry in $z$. I am pretty sure that this slice also has non-vanishing scalar curvature.)