$replace_order = new WC_Cart();
$replace_order->empty_cart( true );
$replace_order->add_to_cart( \"256\", \"1\");
The above code add product
To make it dynamic ( override price for each item in cart separately ), you need to save the override product price in session with cart item key as session key using woocommerce_add_to_cart hook.
by using these session values you can calculate correct Cart Total and make the altered price appear in the Order Item as well