Hershey said on Thursday it had rejected a $23 billion takeover bid by Mondelez International.