A thing can only be "legal" or "not legal" in some system of law. A person cannot be illegal, but a person can do illegal things.
So Haftar isn't illegal, but Haftar might (or might not) have done things that are illegal in Libya.
Now, Libya is in a state of civil war. There isn't a stable government. There isn't a stable set of laws throughout the country. Haftar controls part of the country, in that part he is defacto the local ruler. The LNA controls much more land(pink) than the internationally recognised government(green).
(Image from Wikipedia https://commons.wikimedia.org/wiki/File:Libyan_Civil_War.svg)
Saying "Troops loyal to Hafter" is more accurate than "Haftar's troops". Even though he is local ruler, he doesn't own the soldiers.
If you want to negotiate a peace, you have to negotiate with the people who are doing the fighting. A treaty that excludes some of the fighters will be ignored by those fighters and the war will continue.
Haftar, in particular, has had a role in fighting ISIS that is supported particularly by Egypt. Haftar is aligned to the political stance of the current Egyptian government. Egypt is a sovereign state, and they can invite whoever they want. (And the rest of the world can complain or punish Egypt if the rest of the world wants)