The first form sounds to me the correct one (I'm not English mother tongue), describing a freelance consultant in electronics (or electronic engineering): is it right?
You sense correctly that the first noun in a compound word, i.e., used attributively, is rarely used in the plural. A toothbrush is not for a single tooth, but *teethbrush does not exist. A peach tree also bears more than one peach.
Fields of study or other activities such as:
mathematics, physics, linguistics, phonetics, electronics; athletics, gymnastics
are not true plurals and are always used with a singular verb. Thus the s must remain to indicate they are indeed nouns and not adjectives:
mathematics professor, physics grad student, phonetics book, gymnastics coach
Without the s, an *electronic consultant would suggest a very clever, electrically powered robot. Thus electronics consultant is the word you want.
"electronics" is a noun. "electronic" is an adjective. When a noun is preceded by an adjective, that adjective is understood as directly modifying the noun, so an "electronic consultant" would be a consultant that is electronic. When a noun is preceded by a noun, however, that preceding noun is generally understood to modify the following noun in a more context-dependent way. In the case of "electronics consultant", "electronics" is understood the be the subject matter on which the person consults.