$ cat hostname.yaml
#cloud-config
fqdn: xyz.domain.com
hostname: wxy
$ lxc init ubuntu-daily:xenial x12
$ lxc config set x12 user.user-data - < hostname.yaml
$ lxc start x12
csmith@uptown:~$ lxc exec x12 -- cat /etc/hosts
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
csmith@uptown:~$ lxc exec x12 -- hostname
wxy
csmith@uptown:~$ lxc exec x12 -- hostname --fqdn
wxy.lxd
csmith@uptown:~$