No, you may not do this. Those logos are the intellectual property of the teams and/or the leagues; they are trademarked and/or copyrighted. If you use these logos without permission, you are violating intellectual property; the rights holder(s) can sue you for damages or monetary compensation, and can also obtain court orders requiring you to stop doing this, stop selling the hats, and to destroy all existing inventory. To use these logos, you'd need to get the permission of the rights holders, which will typically mean striking some licensing deal.