Thank you for reaching out to the Microsoft Q&A platform.
If a resource group has a read-only lock, you cannot move any resources from that resource group to another resource group. Therefore, in both scenarios you mentioned, you cannot move the virtual machine to the other resource group if the source resource group has a read-only lock.
A read-only lock on a resource group prevents all users from deleting or modifying any resources in the resource group, including moving resources to another resource group. However, users can still read the resources in the resource group.
If you want to move the virtual machine to another resource group, you need to remove the read-only lock from the source resource group first. Once the lock is removed, you can move the virtual machine to the target resource group using the Azure portal, Azure PowerShell, or Azure CLI.
If this does answer your question, please accept it as the answer as a token of appreciation.