Since the total charge is assembled on the capacitor one point charge at a time, you can use the Chop-Multiply-Add strategy to sum the contribution to the total potential energy made by each point charge.
Chop: Each point charge that moves from one plate to the other can be represented simply as \(dq\text{.}\)
Multiply: The potential energy gained by the point charge as it moves is \(dU = \Delta V(q) dq\text{,}\) where \(\Delta V(q)\) is the potential difference between the capacitor plates, here written as a function of the total charge already on each plate. Note that \(\Delta V(q)\) should increase as more and more charge is moved. The definition of Capacitance allows this to be rewritten \(dU = \frac{q}{C} dq\text{.}\)
Add: Summing from an initial charge of 0 to a final charge \(Q\) gives
\begin{equation*}
U = \int dU = \int_0^Q \frac{q}{C} dq = \frac{1}{2}\frac{Q^2}{C}
\end{equation*}
Reusing the definition of capacitance allows this to be rewritten in various forms depending on the known quantities.
