code: public function changePassword($data)
      {
          /* @var $user UserInterface */
          if (!($user = $this->hydrate($data, $this->getChangePasswordForm()))) {
              return;
          }
  
          $eventManager = $this->getEventManager();
          $eventManager->trigger(__METHOD__, $this, $user);
  
          $password = $user->getPassword();
          $passwordService = $this->getMapper()->getPasswordService();
          $user->setPassword($passwordService->create($password));
          $this->getMapper()->update($user)->save();
  
          $eventManager->trigger(__METHOD__ . '.post', $this, $user);
  
          return $user;
      }
docs: Change user password
  
  @param array|UserInterface $data
  @return UserInterface|void