The funding news comes as U.S. cities and towns, including those in Massachusetts, are increasingly threatened by cyberattacks.