A permanent magnet DC generator (or a generator with constant field excitation) can be modeled as a voltage source proportional to velocity (angular velocity in the case of a rotary generator) in series with some coil resistance.
Since viscous damping requires a force proportional to velocity, simply loading the output of the generator with a variable resistance RL will create a variable damping factor proportional to RL+RG (where RG is the winding resistance). We want the torque to be -c\$v\$ where \$v\$ is the motor rotation speed to simulate viscous damping, so in this case c = \$k(R_L+R_G)\$, where k is a constant that depends on the generator construction.
An electronically-variable resistance can be created by literally switching resistances in and out, or it can be done with a MOSFET or BJT electronic load that simulates a resistance. The maximum damping with a passive load is limited by the internal resistance of the generator. With an active load and external power supply it should be possible to simulate a negative resistance externally to further reduce the total equivalent resistance.
For linear motion, a linear PM motor could be used, or a rack and pinion used to convert linear to rotational motion.
A second method, most useful if motion is guaranteed, would be to use coulomb friction (for example as a caliper and brake pads dragging on a rotor) and control the force applied to the brake pads using a torque motor or other method (for example change the position of an actuator that is spring loaded, so use Hook's law to determine the force). This works because dry friction is proportional to the normal force applied, and the proportionality factor \$\mu\$ is a function of the materials involved
However, this method will have stiction (nonlinear behavior) before motion starts.