Optifine works with Pixelmon as long as you get the versions right. We recommend installing OptiFine 1.12.2 with the latest 1.12.2 version of Pixelmon. You're likely to run into compatibility issues if versions don't match.