I experimented with something like this a couple years ago (Re: dgVoodoo 2 for DirectX 11)
It shouldn't be too difficult, from what I remember. Besides the obvious (replacing IID_IDirect3DHALDevice/IID_IDirect3DTnLHalDevice with IID_IDirect3DRefDevice), I think you need to make sure to create all 3D-related surfaces (textures, render targets, depth buffers) in system memory. HAL devices generally require the opposite, so just replacing the device probably won't work. A copy of d3dref.dll is also needed, which can be obtained e.g. from the DirectX 7 SDK. The DX7 DDK even has the source code for it.
If you expect to have somewhat decent performance though, then IID_IDirect3DRGBDevice might be a better choice, though it supports fewer features. No TnL for example, so I'd assume it can only work with transformed and lit vertices, unlike the reference rasterizer (at least based on the caps in dxcapsviewer). From what I remember, the reference rasterizer had like 1-2 fps in Combat Missions.
It might also be worth checking how caps are reported. I seem to recall SW devices don't report any caps in the HAL structs, but I may be wrong.