You can’t use the max
reduction method in a constant function, so you will have create your own function. It is very simple
localparam WIDTH = max(VAR_A);
function bit[`INT_B-1:0] max(bit[`INT_B-1:0] arg[ARR_SZ ? ARR_SZ : 1]);
max = 0;
foreach(arg[i]) if (arg[i]>max) max = arg[i];
endfunction
If you have many different parameterized array shapes in the same module you can wrap the function as a static method in a parameterized class.