The hostname command outputs the hostname of the system from the systems local hostname configuration (could be /etc/hostname or /proc/sys/kernel/hostname or other depending on OS).
The command ping -c 1 <hostname> is going to perform a lookup through the libc resolver (which may or may not be DNS. e.g., /etc/hosts is not DNS) of the <hostname> specified and then perform a reverse DNS lookup of the IP address returned and report that name in the output of the ping command.
As a concrete example, suppose that the local system hostname is fred as specified in /etc/hostname. The hostname command will return 'fred'. The command ping -c 1 fred will perform a DNS lookup of fred (either just fred or fred fully qualified such as fred.domain.com if default domain is domain.com). Assume that DNS returns IP address x.x.x.x. ping will then perform a reverse DNS lookup of IP address x.x.x.x, if no name is returned ping will output the IP address x.x.x.x, otherwise ping will output whatever named was returned from the reverse lookup which could be a different name such as ethel.domain.com.