Sure. You could have a function like “toggleNav” that you could call, but it would have to have some way of knowing the current state of the nav so it would know what to do. You could store that in a variable or you could read it from the DOM.
You can definitely use a single function. My suggestion is to start by adding a class named side-nav to the same element you current have the id="sideNav". I would make sure the width is set to 0 (which will make it so the side nav is not seen). Then you would create a new class called open-nav and use width: 80%, since this is the width you wanted when the nav is open.
I would also suggest giving an id to each button (i.e. open for the button which opens the side nav and close which closes the side nav).
Finally, you can create a function called something like toggleSideNav that has one argument (‘event’) and gets the value of event.target.id and if it is open, then you add the class open -nav to it. Otherwise, it is assumed the close button was clicked, so you would remove the class open-nav.