I have been told by scholars that the washing machine cycle turns najis clothes into pure ones. However, can I add detergent into the cycle, or would this alter the pure water into mixed water, therefore not purifying the clothes?

Even if you use detergent, the process of washing machines is that first they wash with the detergent then they rinse away the detergent and the last few cycles are only water. In the last cycles the clothes and the full inside of the washing machine gets purified.