How to script a forever going swing?

Now that I have a configurable Joint and made sure my object would only rotate on the y angle, how can I use a simple script to let it swing back and forth eternally?

You could use the Animation Editor:

Create an Animation Clip animating Rotation.y only, set the WrapMode to Loop or PingPong and attach it to the GameObject.