Actually an interesting question! I do not think there is a definition that would give a clear answer, but still let’s try:
Was Lafayette paid for his services? I suppose no.. so not mercenary.
Was France at war with the UK at the time? If so, we can consider him to be a part of French military attached to an ally?
Lafayette was unpaid but Von Steuben and Pulaski were. All volunteered to come to America and held commissions in the Continental Army. Only Lafayette’s home country was at war with Great Britain at the time.
A true mercenary is “for hire” almost to anybody and generally does not fight as a volunteer or for ideological reasons.