To encode a password in symfony, we have to use UserPasswordEncoderInterface to encode the password. It will need to pass the User entity as first parameter for the method encodePassword().
It will be cool if we could do something like
$config->registerMapping(UserDto::class, User::class)
->forMember("password", function($source, $destination) use ($passwordEncoder) {
return $passwordEncoder->encodePassword($destination, $source->password);
});