Unfortunately it's not possible. Currently you cannot restrict a payment method based on the shipping option selected by a customer.
However I can suggest you to add a note to your COD payment method telling your customers that COD is only available is you select the pickup option and that orders made with other shipping options will be cancelled.
You can add a note to your COD payment method by going to Settings -> Payments and clicking on the Edit button on the right of the COD payment method. You can write your note on the Additiona details field.
Let me know if this help!
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...By Ollie Jul 28, 2022