"inferior or petty attorney employed in small or mean business," or, as Henley has it, "An attorney of the baser sort: a sharking lawyer," 1560s, often treated as two words or hyphenated. The first is petty; the second element is probably provincial fogger "a huckster; a cheat, one who engages in mean or disreputable practices," which is perhaps from obsolete Dutch focker, from Flemish focken "to cheat," or from Middle English fugger; both words seem to be from Fugger the name of the renowned family of merchants and financiers of 15c.-16c. Augsburg. In German, Flemish and Dutch, the surname became a word for "monopolist, rich man, usurer."
A 'petty Fugger' would mean one who on a small scale practices the dishonourable devices for gain popularly attributed to great financiers; it seems possible that the phrase 'petty fogger of the law,' applied in this sense to some notorious person, may have caught the popular fancy. [OED first edition]
However, OED also calls attention to pettifactor "legal agent who undertakes small cases" (1580s), which, though attested slightly later, might be the source of this. Related: Pettifoggery.
A pettie fogger, a silly aduocate or lawyer, rather a trouble-Toune, hauing neither law nor conscience. [Minsheu, "Guide to Tongues," 1627]