Obviously - I hope it's obvious - you can't lengthen cables.
Shortening is relatively easy. A new one to shorten is best, as lube makes attaching a new barrel nipple (or other end fitting) more difficult.
You need a pretty hot torch and some silver solder plus its special flux. Normal solder is too soft and the end can pull off, don't trust it. Silver solder is strong but needs a higher temperature than a propane torch produces. Maybe MAPP but I haven't tried it. Silver solder is expensive... (duh, silver) but jewelry places may sell you just an inch or two, and give you a dab of flux.
If the existing nipple is soldered on, heat it up and pull it off. Remove the solder from the hole by heating it up and smacking it against a hard thing so the liquid metal shoots out.
The ferrule on the sleeve can be tough to remove, heating it and pulling works. You probably have to enlarge it to fit on again.
Pull the core back and cut the sleeve to the length you want. A super fine hacksaw is ok, cutting pliers will just make a mess with the spiral steel all screwed up. You can use a grinder but the plastic is going to melt.
Get the ferrule back on, it is important. If it's loose, either accept that or use some glue. If it goes in a typical holder, being loose doesn't much matter.
Push the core through and mark where you want the nipple.
(If you had to cut the original off, there are nipple and ferrule kits you can buy. The setscrew emergency nipples are just that: they will come loose or pop off when most inconvenient OK - to get home but replace or repair the cable properly.)
Once marked, put a small dab of flux where you want the nipple. Heat up and tin the cable with the silver solder, use as little as possible avoiding having solder wick in very far away.
Reused nipples already have a coating of the solder. New ones, smear some flux in the hole and on the tinned spot on the cable. Thread the core through and position it where you tinned. Heat it up and touch the solder right at the hole. You can see when it wicks in, if it doesn't then likely it isn't hot enough. That's it, let it cool naturally then clean off excess flux with solvent. Gasoline should work. Then cut off the protruding core. File or grind off the stub if it can poke anyone once mounted, the cut off end is sharp.
A used cable will probably be saturated with lube. Clean where you want the nipple as well as possible with a really good solvent, a few inches either way. Acetone is probably one of the best for this. You want the strands clean inside, as the solder should stick them all together as well as to the nipple. Even a new cable should be cleaned with acetone before soldering.