You probably (could) use `acpid` (check via `ps aux | grep acpid`). Then have a look at this article in the ArchWiki explaining how to use `pm-utils` to extend `acpid` to easily achieve whatever effect you'd like when some hardware button is pressed.
If, however, you use GNOME, there other (also GUI) ways, see this comprehensive thread on `askubuntu.com`