マイページでのメルマガ配信ON/OFFですが、Liquidではなぜか出来ないため、APIを使うしかありません。
外部サーバーから以下の Customer APIにアクセスして「accepts_marketing」をfalseかtrueで更新します。
PUT /admin/api/2020-10/customers/{customer_id}.json
▼Customer API
https://shopify.dev/docs/admin-api/rest/reference/customers/customer#update-2020-07