I know it is sometimes done that way in piping schedules / specifications etc, but pipe is NOT rated by ASME class rating. It is designed by pressure containment, temperature, corrosion, material strength and other forces to a certain design code.
So yes, if the pipe is the same thickness as your ASME class 2500 flange / valve then you can weld it HOWEVER, the pressure rating of the system to which the class 2500 valve is welded to may not be the same maximum pressure rating as the flange / valve.
Now why you would want to use a higher pressure rated valve instead of a lower one is not clear.
It can be confusing in the long run to use higher rated flanges as then everyone thinks the entire system is good for class 2500 when it's not. Things like this get lost in the mists of time so mistakes can be made later.
Remember - More details = better answers
Also: If you get a response it's polite to respond to it.