There's no simple method. But it's doable for files which are part of an RPM:
rpm -qf for a given filename identifies the package
rpm -qi for a given package tells a little about where the program came from.
- In particular, if it's a CentOS package, you can find a source-rpm (".srpm") on CentOS's web/ftp-server. That can be unpacked to get the source-tarball and patches.
If it's not in an RPM, it's hard to find the source unless you know how the file got there. For non-CentOS packages, the packager may identify the source location, maybe not.
For instance, your example
hostname might be provided by coreutils, but RPM says it is not:
$ rpm -qi `rpm -qf /usr/bin/hostname`
Name : hostname
Version : 3.13
Release : 3.el7
Install Date: Fri Jul 4 13:23:13 2014
Group : System Environment/Base
Size : 19449
License : GPLv2+
Signature : RSA/SHA256, Thu Jul 3 21:54:35 2014, Key ID 24c6a8a7f4a80eb5
Source RPM : hostname-3.13-3.el7.src.rpm
Build Date : Mon Jun 9 17:48:44 2014
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://packages.qa.debian.org/h/hostname.html
Summary : Utility to set/show the host name or domain name
This package provides commands which can be used to display the system's
DNS name, and to display or set its hostname or NIS domain name.
Since the Vendor is
CentOS, you can find the source on CentOS's site. Or you could follow the given URL (which can take some work). In this case, Debian offers a link to browse the source code, because Debian maintains the program. In cases where they do not, often a tar-ball is the best you'll find.