As a general rule, failure to comply with a court order is not contempt of court if compliance is impossible. In the unusual scenario you describe, the outcome will depend on the specific legal obligation in question, as well as the opposing party's attitude (eg whether they accept, as a matter of fact, that compliance requires the producing party to pay fees that they cannot afford).
If the obligation to produce documents arose from a subpoena issued in accordance with rule 45 of the Federal Rules of Civil Procedure, subsection (e)(1)(D) would apply:
Inaccessible Electronically Stored Information. The person responding need not provide discovery of electronically stored information from sources that the person identifies as not reasonably accessible because of undue burden or cost. On motion to compel discovery or for a protective order, the person responding must show that the information is not reasonably accessible because of undue burden or cost. If that showing is made, the court may nonetheless order discovery from such sources if the requesting party shows good cause, considering the limitations of Rule 26(b)(2)(C). The court may specify conditions for the discovery.
Similarly broad powers to set aside or modify a subpoena which imposes an "undue burden" on the recipient exist under other civil procedure statutes. As you suggest, one way around the problem might be to direct the subpoena to the entity requesting the fee. That entity might then also apply for the subpoena to be set aside unless its costs are paid by the issuing party. Again, the outcome depends on all of the unusual circumstances that led the issuing party to fund litigation against a responding party who, according to the question, cannot afford to pay document storage fees, let alone any damages or costs ordered by the court.
The position is different in criminal litigation against the responding party. Normally documents of the accused would be obtained under search warrant, potentially from a third party, rather than (perhaps impermissibly) expecting the accused to assist the prosecution by complying with a court order to produce documents. Different laws and procedures govern disputes about the proper scope of criminal investigation powers.
These include both state and federal laws, so any connection to multiple states is important and potentially changes the applicable law. The fact that the target of these compulsory powers is a lawyer, however, is probably not that important. The general law of subpoenas would still apply, although a lawyer's documents would commonly be subject to privilege, and a lawyer might also face professional sanction for losing access to their practice records through financial mismanagement.