Alright, so here the steps I followed to get GDB installed under macOS Sierra using HomeBrew (MacPorts and Fink is an option as well).
1. Install HomeBrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
2. Install GDB
brew install gdb
3. Create a certificate for code signing
Start the Keychain Access application (Applications -> Utilities -> Keychain Access.app).
Open the menu item Keychain Access -> Certificate Assistant -> Create a Certificate...
Choose a name (gdb-cert for example),
set Identity Type to Self Signed Root,
set Certificate Type to Code Signing and
check the Let me override defaults option.
Click several times on Continue until you get to the Specify a Location For The Certificate screen, and set Keychain to System.
Right click the new certificate in the list, select Get Info, open the Trust item, and set Code Signing to Always Trust.
Finally, quit Keychain Access application to refresh the certificate store.
It is best to reboot your computer now to refresh everything, but you can also kill and restart taskgated but that seems the less reliable method.
4. Code Sign GDB
Assuming that the certificate is known as gdb-cert, use:
sudo codesign -s gdb-cert gdb
The easiest way is to first cd to the location of GDB, or specify the full path (mine was located in /usr/local/Cellar/gdb/7.12.1/bin).
5. GDB tweaking for Sierra (might not be needed)
For macOS 10.12 (Sierra) and later, you must gdb 7.12.1 or later.
Additionally prevent gdb from using a shell to start the program to be debugged.
You can use the following command for this inside gdb:
set startup-with-shell off
You can also put this last command in a file named ".gdbinit" in your home directory, in which case it will be applied automatically every time you start gdb.