County sheriffs and their deputies, when on duty, shall be dressed in a distinctive uniform which shall be furnished by the county, and display a badge of office: Provided, The wearing of such uniform and badge shall be discretionary at the option of the sheriff when he or his deputies are engaged in special investigations or mental patient assignments: And provided further, That special deputies appointed by the sheriff, detectives, clerical personnel and civil process servers; and deputies while engaged in the transportation of prisoners may be excluded from the requirements of this section at the option of the sheriff.