How to Simulate drone position hold in Unity

I’m working on a drone simulator in Unity.

I created a code to control attitude, altitude, and position using PID.
However, with position control, if you perform a yaw operation, the aircraft will head in the opposite direction.

Is there a control method that takes into account the rotation of the drone?

void Position_Hold()
    if (input1.x == 0 && input1.y == 0)
        float X = Vector3.Dot(transform.position, Vector3.right);
        float Y = Vector3.Dot(transform.position, Vector3.forward);
        input1.x = pidPosX.ComputeInput(X, targetPos.x, Time.deltaTime);
        input1.y = pidPosY.ComputeInput(Y, targetPos.y, Time.deltaTime);
        targetPos = new Vector2(transform.position.x, transform.position.z);

Applying rotation control in local should do the trick

I would use the PID controller to change the forces applied to a Rigidbody based on current angular velocity / desired rotation ,etc. You can then use Rigidbody.AddRelativeTorque to apply to correct axis in relation to the drones current local rotation.