The rules of casino blackjack specifically disallow card counting. So, assuming that you playing blackjack in a casino constitutes an enforceable agreement between you, it would be illegal to count cards, just as it’s illegal to breach any contract.
Which isn’t to say it’s necessarily criminal, but there’s certainly an argument for fraud. You go to a casino expecting to lose*, so attempting to change the odds into your favour is at least morally fraudulently enriching yourself.
*At least, you should do, if you have any sense. If you had much sense, you wouldn’t be there at all.