Ammo can absolutely be tailored to shorter barrels.
The faster the powder, the faster the bullet accelerates early in the barrel.
There are variables and complexities, but you can certainly build ammo better suited for longer or short barrels.
There's usually not much you can do to make changes with "similar" barrel lengths. The powder that produces the best velocity in a 5" barrel will probably also be best in a 4" barrel but when you start getting more dramatic difference, like 8" versus 3", more can be done.
You can also make changes that might not change the velocity but might reduce muzzle blast and flash.