I just started learning MEL and I came across this script on cgtalk, maybe it can give you a clue at least.
Going to try it when I get home.
string $obj = `ls -sl`;
float $RandomValue = .5;
for ($i=0; $i < size($obj);$i++)
setAttr ($obj[$i] + ".rotateX") `rand $RandomValue`;
setAttr ($obj[$i] + ".rotateY") `rand $RandomValue`;
// setAttr ($obj[$i] + ".rotateZ") `rand $RandomValue`;
Remember to change "float $RandomValue = .5;" to a number that is good for you- and I'm not certain that you need " string $obj = `ls -sl`;"
And have in mind that "// setAttr ($obj[$i] + ".rotateZ") `rand $RandomValue`;"
was writen like that becouse he didnt want it to rotate in the Z axis so just remove those slashes to active the Z axis to.
Edit: And Benny have in mind that you need to know MEL to make scripts but not to copy them so just ask for help and things like this can be done.
You should be able to key it like usual to animate it.
Second edit: I tried the script and it worked perfectly just copy paste and change your attributes, it worked good when keyed to.