For searching purposes:

FreeBSD:
/etc/rc.conf
hostname="foo"

Gentoo:
/etc/hostname
foo