TL;DR: Your formula is too simple.
So the problem is why "" has an entropy if 0 with your formula, but MD5("") has not 0.
As said already in the comments, your formula only works if the data is perfectly random (uniform distribution, all bits independent, etc.).
Example for random case: Your PIN calculation with 4 digits between 0 and 9.
But if you have eg. some value that can either be 2222 or 7777 and nothing else, the entropy is just 1 bit. There are still 4 digits, but most 4-digit numbers are not possible, so your formula doesn't work anymore.
The same is true for your hash - hashing a 0-length string gives exactly one output, always the same. Not 256^16 possibilities that 16-byte hashes can have.
A better formula:
H(X) = sum (-p[i] * log2 p[i])
p[i] is the probability of the i-th possible value (not digit etc., but value - your PIN has 9999 possible values, and each one has its own probability).
With this formula and the one single possible hash value, you get 0 too.
In general, a hash like this never can increase entropy. It may be the same or less than the one of the original value (less especially if the data is longer than the hash, ie. the hash has less possible values)