Well, it's blissfully straightforward.
(Sorry, wrong kind of "Yes!". Anyway, it's still "Yes.")
Umm, Yes. (Or at least "Maybe", depending on proportionality and military advantage.)
Colonel Gaddafi is both the de facto Head of State of Libya, and the de facto Commander-in-Chief of the Libyan armed forces. As such, he's a legitimate military target within the meaning of AP I, and within the remit of UNSCR 1973. Therefore, if the killing of Colonel Gaddafi was proportionate to the military advantage, and was proportionate to the risk posed to non-combatants, then yes, it will be legal.