Catalysis of the reaction: S-adenosyl-L-methionine + DNA containing CpNpG = S-adenosyl-L-homocysteine + DNA containing 5-MeCpNpG.
DNA (cytosine-5-)-methyltransferase activity, acting on CpNpG substrates