Custom plugin contact form connecting to mailchimp API

Change your code like this

// Enter here the MailChimp API key
$apiKey = "";
// Enter here Mailchimp list id
$list_id = "";

$server = explode( '-', $apiKey );

$url="https://" . $server[1] . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/';

$response = wp_remote_post(
    $url,
    [
        'method'      => 'POST',
        'data_format' => 'body',
        'timeout'     => 45,
        'headers'     => [
            'Authorization' => 'apikey ' . $apiKey,
            'Content-Type'  => 'application/json; charset=utf-8',
        ],
        'body'        => json_encode(
            [
                'email_address' => '',//email
                'status'        => 'subscribed',
                'status_if_new' => 'subscribed',
                'merge_fields'  => [
                    'FNAME' => '',// first name
                    'LNAME' => '',// last name
                    'PHONE' => ''//phone
                ]
            ]
        )
    ]
);