Here is a solution that handles overflow as well. It can pad any number:
$ jq '3 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 1}'
"001"
$ jq '3 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 12}'
"012"
$ jq '3 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 123}'
"123"
$ jq '3 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 1234}'
"1234"
with any number of leading zeros:
$ jq '4 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 1234}'
"1234"
$ jq '5 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": 1234}'
"01234"
and this handles negative numbers as well, by ignoring/treating them as 0:
$ jq '3 as $pad | (fmax(0;.aNumber)|tostring) as $N|($N|length) as $D|[range($pad) as $_|"0"]|join("")[fmax($D; $D-$pad):]+$N' <<<'{"aNumber": -123213}'
"000"
def lpad(n): if . < 0 then "-" else "" end + (length | tostring | if (n > length) then ((n - length) * "0") + . else . end);
– Zurheide