Modular and threshold subword counting and matrix representations of finite monoids