@NatoBoram answer is my favorite. A tiny supplement for elementary OS 5.0 (Juno) and 5.1 (Hera) the answer works.
Windows-like layout (three buttons on top right corner):
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DecorationLayout': <':close,minimize,maximize'>}"
MacOS-like layout (three buttons on top left corner):
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DecorationLayout': <'minimize,maximize,close:'>}"
I prefer this layout (close button on the left, minimize and maximize buttons on the right):
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DecorationLayout': <'close:minimize,maximize'>}"
NOTE: do not leave any space in 'close:minimize,maximize'
.