$ pacman -Syu
then, press <esc><esc>, and the command will be:
$ sudo pacman -Syu
or, add sudo to the previous command if nothing is type yet.
Add sudo plugin which bind \e\e to add sudo in front of the command
Unfortunately a later PR merged this same functionality: #1947.