In this blog I’ll explain you how we can change customer password programmatically.

$customerId = 10; // here assign your customer id
$password = "your_password"; // set your custom password
$customer = $this->_customerRepositoryInterface->getById($customerId); // _customerRepositoryInterface is an instance of \Magento\Customer\Api\CustomerRepositoryInterface
$customerSecure = $this->_customerRegistry->retrieveSecureData($customerId); // _customerRegistry is an instance of \Magento\Customer\Model\CustomerRegistry
$customerSecure->setRpToken(null);
$customerSecure->setRpTokenCreatedAt(null);
$customerSecure->setPasswordHash($this->_encryptor->getHash($password, true)); // here _encryptor is an instance of \Magento\Framework\Encryption\EncryptorInterface
$this->_customerRepositoryInterface->save($customer);