I don't know about other elements of international humanitarian law, but the first protocol to the Geneva conventions has this to say about mercenaries in its Article 47:
Article 47 -- Mercenaries
A mercenary shall not have the right to be a combatant or a prisoner of war.
A mercenary is any person who:
(a) is specially recruited locally or abroad in order to fight in an armed conflict;
(b) does, in fact, take a direct part in the hostilities;
(c) is motivated to take part in the hostilities essentially by the desire for private gain and, in fact, is promised, by or on behalf of a Party to the conflict, material compensation substantially in excess of that promised or paid to combatants of similar ranks and functions in the armed forces of that Party;
(d) is neither a national of a Party to the conflict nor a resident of territory controlled by a Party to the conflict;
(e) is not a member of the armed forces of a Party to the conflict; and
(f) has not been sent by a State which is not a Party to the conflict on official duty as a member of its armed forces.
It's therefore not possible to answer the question generally; whether any individual is a mercenary depends on the facts surrounding that individual's participation in the conflict, including, crucially, the individual's motivation. Internal states of mind such as motivation are typically difficult to prove. It is certainly possible that some of these people are mercenaries.
a Russian passport automatically makes a Wagner militants a combatant, doesn't it?
Not necessarily. As the source cited in the question notes, a Russian citizen participating in the conflict could in some circumstances be a civilian who is not a combatant and may therefore be prosecuted for participating in the hostilities.
Regular Ukrainian servicemen can't prove or disprove their reported link to Russia's General Staff on the spot. How are they supposed to treat Wagner militants?
Generally, in cases of doubt, any person is to be presumed to enjoy protections until it has been shown otherwise. For example, Article 45 of the protocol:
Article 45 -- Protection of persons who have taken part in hostilities
A person who takes part in hostilities and falls into the power of an adverse Party shall be presumed to be a prisoner of war, and therefore shall be protected by the Third Convention, if he claims the status of prisoner of war, or if he appears to be entitled to such status, or if the Party on which he depends claims such status on his behalf by notification to the detaining Power or to the Protecting Power. Should any doubt arise as to whether any such person is entitled to the status of prisoner of war, he shall continue to have such status and, therefore, to be protected by the Third Convention and this Protocol until such time as his status has been determined by a competent tribunal.
If a person who has fallen into the power of an adverse Party is not held as a prisoner of war and is to be tried by that Party for an offence arising out of the hostilities, he shall have the right to assert his entitlement to prisoner-of-war status before a judicial tribunal and to have that question adjudicated. Whenever possible under the applicable procedure, this adjudication shall occur before the trial for the offence. The representatives of the Protecting Power shall be entitled to attend the proceedings in which that question is adjudicated, unless, exceptionally, the proceedings are held ' in camera ' in the interest of State security. In such a case the detaining Power shall advise the Protecting Power accordingly.
Any person who has taken part in hostilities, who is not entitled to prisoner-of-war status and who does not benefit from more favourable treatment in accordance with the Fourth Convention shall have the right at all times to the protection of Article 75 of this Protocol. In occupied territory, any such person, unless he is held as a spy, shall also be entitled, notwithstanding Article 5 of the Fourth Convention, to his rights of communication under that Convention.