How is the YAW angle calculated by an IMU sensor?

Say a body rotates by 90 degrees, then the yaw angle will be 90 which can be calculated using the data provided by IMU.

Now from that point, the body traverses some distance and is again rotated by 90 degree in the same direction. What will be yaw angle shown by the IMU? Will it be 180 degrees or 90 degrees?

In a nutshell what I want to ask is that, is the angle measured from the initial starting point or from the last reference point? For Roll, Pitch, Yaw, please refer to the above diagram.

First of all, a lot of different devices come b under the umbrella of imu.

To my understanding most imu sensors report angular rates. So it's very common in the scenario you have submitted to get 90 degrees instead of 180. ( keep in mind that they report degrees per second or similar units).

There are of course higher grade imu's that combine several sel sensors(accelerometers, gyroscopes, and magnetometers). These are able to provide absolute angular measurements. However, they are costly.

There are other contributors with more experience in aviation here that might give a more illuminating insight.

So bottom line; IMHO it depends on the implementation of the imu sensor.

The yaw angle is defined as the difference between the body's orientation vector and velocity vector in the yaw plane of the body.

So the IMU computes the velocity vector using integrating accelerometers and computes the orientation vector using gyrocompasses. It then compares the two and extracts pitch, roll, and yaw angles. The way it does this depends on whether you are using a strapdown IMU or a gimballed inertial platform.

To answer your question, you have to tell us in what direction the vehicle is moving.