Any officer who has the power or authority to take complaints and issue warrants of arrest, and who acts as an attorney in any such case in which he or she took the complaint or issued the warrant, or heard the examination or tried the case in any court on preliminary examination or appeal or trial before a jury, must, on conviction, be fined not less than $50 nor more than $500.