In which situation is HMAC mandatory rather than signature?
In principle, a signature can always be used in lieu of a MAC. You use a MAC when you want the legitimate recipient of a message to be able to verify its authenticity. With a signature, everyone, including of course the legitimate recipient, can verify the authenticity of a message.

The reason we use MACs at all, instead of just using signatures all the time, is of course that MAC constructions are more efficient. Thus an answer to the question could be: when a signature is not efficient enough for your purposes.