Municipal police will test the scheme in the two city districts where the biggest concentration of dog droppings have been found, city hall said in a statement.
Dog owners who do not clean up after their pets will be fined up to 1,500 euros (B59,437) or they will have the option to perform street cleaning duties for a few days as a substitute, it added.
Madrid city hall said “there is still excrement in the streets, parks and other places” despite “repeated public awareness campaigns” and the distribution of millions of free bags to collect dog poo.
“The municipality has prepared a shock plan against these infractions which will start to be deployed shortly in two districts,” it added.
Several Spanish cities have come up with creative ways to crack down on dog droppings in recent years.
Last year the north-eastern city of Tarragona announced it would use DNA analysis of dog droppings to track down owners who fail to clean up after them.
During a brief period in 2013 the town of Brunete near Madrid delivered dog poo back to the homes of pet owners who left it behind, in boxes marked “Lost Property”.
Volunteers would strike up conversations with unsuspecting, offending pet owners after their pooch had done its business to obtain its name and species, which would then allow city officials to identify them and find their address from a registered pet database.