In its earliest sense, as in Shakespeare’s day, the word “Madcap” meant simply one who was crazy, a maniac.
Cap, just because it covered the head, was sometimes used for “head,” and mad, used literally, meant “crazy.”
Of course it was also used, and still is, somewhat playfully, in describing one who acted impulsively or recklessly, in much the same manner as we now say, “He’s got bees in his bonnet.”