From this article:
Although the first Maratha ruler, Shivaji, freely recruited Mahars in his army, two centuries later, by the time of the Peshwas, the status of Mahars was lower than ever. The Peshwas were Brahmins of a particularly orthodox bent. Stories told even today recall how when Mahars entered towns, they were made to tie brooms behind their backs to sweep up the dust of their footprints and to tie pots in front on their necks to collect their spittle. It was also a criminal offence to hide one’s caste.
What do śastras say about hiding one's caste? Is it a punishable offense?