I see many definitions online for z spread with formulas written for a bond, how do they change if the bond is callable? Or is z spread calculated to maturity in this case?
It is not a good idea to ignore the call feature and to calculate spreads, yields, risks, and other bond maths to maturity. For many callable bonds, clearly the issuer is certain to call the bond much earlier. Then the spreads and risks (dv01..) would be very misleading.
Practically, the most common methodology is to calculate yield to worst, and then to calculate all spreads, risks, etc to the call date that gave rise to the YTW. This works well enough for bonds where the probability of exercise is close to 1.
However this is not good when the yield from exercising soon is very close to the yield to maturity. The YTW date might change frequently, and the spreads and risks might jump by a lot. For these situations, instead of Z-spread, try option adjsted spread (OAS); and include vega with your risk measures.
In rare cases you just know that the issuer will or will not exercise for some reason irrespective of what yield appears to be worse. For this, you want to be able to manually specify the expected call date and skip the ytw analysis.