Is card counting in a casino considered illegal?

It's not illegal in the sense that you will be prosecuted if caught; however, they will eject you from the casino and possibly blacklist you from returning.