In Hartshorne, a closed immersion of schemes is defined to be a scheme morphism $\Phi \colon Y \to X$ such that $\Phi$ is a homeomorphism onto $\Phi(Y)$, $\Phi(Y)$ is closed in $|X|$ and $$ (*) \hspace{1cm}\Phi^\# \colon \mathcal{O}_X \to \Phi_* \mathcal{O}_Y \text{ is surjective.} $$
Can I replace $(*)$ by the condition that $\Phi^\#_U \colon \mathcal{O}_X(U)\colon \to \mathcal{O}_Y(\Phi^{-1}(U))$ is surjective for all affine open subsets $U \subseteq X$, or does this lead to another definition?
It is equivalent. We have a short exact sequence of sheaves
$$0 \to I_Y \to \mathcal{O}_X \to \Phi_*\mathcal{O}_Y \to 0,$$
where $I_Y$ is the ideal sheaf of $Y$. This is quasicoherent on $X$, so if we restrict to an affine open set $U \subset X$, the associated sequence of global sections
$$0 \to I_Y(U) \to \mathcal{O}_X(U) \to \Phi_*\mathcal{O}_Y(U) \to 0$$
is again exact. (See Hartshorne II.5.6 and II.5.9.)