Yes, it works exactly like that.
Since the variables $X_i$ for $1 \leq i \leq n$ are independent, and each $e^{\lambda X_i}$ is a function of $X_i$ and no other $X_j$ with $j \neq i$, the variables $e^{\lambda X_i}$ for $1 \leq i \leq n$ are also independent. See, for example, this question and its answers. This gives us
$$
E[e^{\lambda\sum_{i=1}^nX_i}]=E[\prod_{i=1}^n e^{\lambda X_i}]=\prod_{i=1}^n E[e^{\lambda X_i}].
$$
Next, as you already mentioned, we get from identical distribution of the $X_i$ for $1 \leq i \leq n$
$$
E[e^{\lambda X_i}] = E[e^{\lambda X_1}] \qquad for \qquad 1 \leq i \leq n
$$
and thus
$$
\prod_{i=1}^n E[e^{\lambda X_i}]=\Big(E[e^{\lambda X_1}]\Big)^n,
$$
as desired.