That's certainly possible, but you might have do some tests to find the exact forces needed so that it works to your satisfaction.
Almost all joints can have a "motor" which you can enable and which applies a force to your joint. So in your case you have to set:
You'll have to experiment with the torque.. I suggest you start with a pretty high value, so that the motor doesn't get hindered too much by other objects or objects attached to the joint.
Also, if you want to limit the joint movement, you have to enable the joint limits. In the following example the joint would be limited to -90 to 90 degrees.
myJoint->SetLimits(-90.0f * DEGTORAD, 90.0f * DEGTORAD);
The only thing left to do is to check if the joint reaches a limit and then switch direction. So in your update loop you would do something like:
float speed = myJoint->GetMotorSpeed();
float angle = myJoint->GetJointAngle();
if((speed < 0.0f && angle <= myJoint->GetLowerLimit()) ||
(speed > 0.0f && angle >= myJoint->GetUpperLimit())
// reverse motor speed whenever we overshoot limits
myJoint->SetMotorSpeed(speed * -1.0f);
That should make your joint swing around from -90 to 90 degrees.