Can you use an old panel as a junction box after removing the guts?
Yes, this is legal and inspectors see it on nearly every service relocation. NEC 2023 312.8(A) permits cabinets and cutout boxes to contain splices and feed-through conductors as long as the wiring space rules are met, and a panel enclosure with the interior stripped is simply a large metal cabinet. It is the standard way to extend existing branch circuits out to a new panel location without opening every wall.
The 75 percent and 40 percent numbers
312.8(A) gives you two limits. Splices and taps must not fill the wiring space to more than 75 percent of its cross-sectional area at any point, and the conductors themselves must not fill it beyond 40 percent. A gutted 30-space panel can has a huge wiring space, so a typical house worth of branch circuits spliced through passes with room to spare. Keep the splices dressed so no single cross section gets crowded.
What has to happen to the old can
Remove the interior or render it dead, terminate every conductor on wirenuts or listed connectors, and bond the enclosure: the EGCs land on a ground bar attached to the can, keeping the fault path continuous to the new panel. Install a blank cover, the old panel cover with the breaker openings is not acceptable because 408.7 style openings must be closed and the deadfront no longer has an interior behind it. A flat steel cover or the original cover with all openings blanked works. The box must remain accessible per 314.29 principles, so no drywall over it.
Neutrals need care
The old can almost always sat where neutrals and grounds were bonded together. Once it becomes a junction box downstream of the new service disconnect, neutrals must be spliced through insulated and isolated from the enclosure and from the EGCs. Reusing the old bonded neutral bar as a splice point is the classic mistake that creates parallel neutral current on the ground path.
Field notes
Label the cover, something like Junction box, fed from panel A, keeps the next electrician from hunting. If the old can is rusted, undersized, or a brand with a bad reputation, the enclosure itself is still just steel and stays legal, but photograph the finished splice work before the blank cover goes on. It is the cheapest documentation you will ever produce.