How do I use variables in functions/procedures

Once you have that array created, your for-loop can become

for (int x=5;x < 9; x++)
{
  byte pin = ledPin[x];

Now you have the shift register pin number, you need to figure out which shift register that is and which bit within that shift register.

  byte sr = pin / 8;
  byte srBit = pin % 8;

Alternatively, and perhaps more efficiently

  byte sr = pin >> 3;
  byte srBit = pin & 7;

Then you can set up your byte array to shift out to the shift registers

  byte shiftBytes[5] = {0, 0, 0, 0, 0};
  bitWrite(shiftBytes[sr], srBit, 1); 

Then you can shift out those bytes to the shift registers as before.