One way would be like Little Snitch
This has two fields for the name
Default is the type Hostname and then a box giving the hostname apple.stackexchange.com
If you change the type to domain then the address box alters to stackexchange.com
In both cases you can edit the address in the box but I don't think that is necessary