You have a couple of options, the easiest one is to just use !! to tell bash to use the last command.

For instance, if you tried to type this, you’d get an error that you are editing a read-only file:

Once that happens, then you can just use this command:

Which bash will then expand into this command:

Screenshot of this in action:

An alternative method would be to just hit the up arrow key, hit either the Home key or Ctrl+A, and then type sudo.