First of all, it is quite logic that r.walk guide you along the riverbed. This is usually the path to walk along. If you change the rivers values to 9999, you will create artificial cliff that will be difficult to cross, and if you climb on it you will try to stay on it. Otherwise, you will just follow the riverbed with one pixel shift. I would instead suggest to use the rasterized river as a friction layer or to play with some parameters of r.walk
EDIT: after rasterizing, use
gdal_edit.py -unsetnodata your_rasterized_polygons.tif
to remove the nodata values of your raster
That being said, you can achieve what you want to do by combining the two comments to your question.
1) use gdal_rasterize to convert your lines to raster based on your attribute field that contains the 9999 values.
2) use the raster calculator to update your DEM with the new raster value
("yourrivers@1" != 9999) * "yourdem@1" + ("yourrivers@1" = 9999) * 9999