[guided]The only difficulty in Replacement is not forming the image in the ambient universe; the ambient universe already satisfies Replacement. The difficulty is proving that the image set has rank below $\kappa$, so that it belongs to $V_\kappa$.
Let $a \in V_\kappa$, let $p_1,\dots,p_n \in V_\kappa$ be parameters, and suppose that a formula $\varphi(u,v,p_1,\dots,p_n)$ defines a function on $a$ inside $(V_\kappa,\in)$. This means that for every $u \in a$ there is exactly one $v \in V_\kappa$ such that
$(V_\kappa,\in) \models \varphi(u,v,p_1,\dots,p_n)$.
Define the image set in the ambient universe by
$Y = \{v \in V_\kappa : \text{for some } u \in a,\ (V_\kappa,\in) \models \varphi(u,v,p_1,\dots,p_n)\}$.
The satisfaction relation is legitimate here because $V_\kappa$ is a set, not a proper class.
We first bound the cardinality of $Y$. Since the formula defines a function on $a$, each element of $Y$ is the value associated to at least one element of $a$, so $|Y| \le |a|$. Choose $\alpha < \kappa$ with $a \in V_\alpha$. Then $a \subset V_\alpha$, and the closure fact above gives $|V_\alpha| < \kappa$. Hence $|a| < \kappa$, and therefore $|Y| < \kappa$.
Cardinality alone is not enough: a small subset of $V_\kappa$ could still have elements with ranks cofinal in $\kappa$ unless regularity prevents this. For each $v \in Y$, let $\rho(v)$ denote the rank of $v$, and define
$R = \{\rho(v) : v \in Y\}$.
Since every $v$ lies in $V_\kappa$, each $\rho(v)$ is below $\kappa$. Also $|R| \le |Y| < \kappa$. Regularity of $\kappa$ now gives
$\sup\{\rho(v)+1 : v \in Y\} < \kappa$.
Call this supremum $\beta$. Then every $v \in Y$ lies in $V_\beta$, so $Y \subset V_\beta$. Hence $Y \in V_{\beta+1}$, and because $\beta+1 < \kappa$, we conclude $Y \in V_\kappa$.
Thus the image demanded by the Replacement axiom is not merely externally present; it is internally present as an element of $V_\kappa$.[/guided]