A bankruptcy judge has approved Core Scientific's plan to replace a previous loan with new financing from B. Riley.