The hash_hmac function takes binary input, i.e. strings made of raw bytes. Character encoding should not come into play at all.
For example, if you were to use SHA256 to compute the HMAC key, from a password, you'd do something like this:
// second parameter selects raw bytes or ASCII hex for output (false = hex, true = raw)
$hmac_key = hash("sha256", $password, true);
// last parameter is, again, whether or not to output raw bytes
echo hash_hmac("sha256", $data, $hmac_key, false);
Assuming the password is "polynomial", the $hmac_key variable should be:
61890d2331f470cb4caeda6035ae27809bee14a42ba3e024ebcfeec9086764d0
Note that this is a hex representation of the contents of the variable - in reality it'll contain raw bytes. Now let's assume that our message is "Hello there!". The result is as follows:
e075d7284eb03baedabb7c27ae1e9f271e763b67c776f3894417f310378da10b
(the above was generated by QuickHash)
HMAC schemes require that the key length is equal to the block size of the hash. Some implementations use a hash algorithm to produce the correct size if the input it larger or smaller than the block size. Usually the hash algorithm used is the non-HMAC version of whatever you're using. I'm unsure as to whether PHP does this, and (if they do) what method they use.