It should not be hard to do that. The Value::Complex class could certainly be used as a template, and basically you would just have to modify the routines like add and multiply to do the right things for quaternions, and remove or add any functions that need to be implemented. That would get you the basic functionality.
It might also be good to add a Parser class based on Parser::Complex, though that might not be strictly necessary. There are some places in the parser where it knows about numbers versus complex numbers, and it might be valuable to add in special handling for quaternions as well, but it might simply be sufficient to mark them as complex numbers and let them be handled that way for now. There might also need to be a subclass of Parser::Function to handle some of this as well.
In any case, it should not be all that hard, and the complex class(es) should be the right starting place.