Image 1 has a red sphere. Make sure you are on frame 1 in your timeline. (image 2) Now open up the Attribute Editor for your material. (image 3) RIGHT CLICK where it says "color" (directly to the LEFT of the red color box) and a menu will appear, which is shown in image 4. Select "Set Key". This keyframes the color attribute as red on frame 1. Now go to frame 20 as shown in image 5. Change the color in the Attribute Editor window to blue. Right-click the word "color" again and select "set key". Now you have keyframed it so that it is the color blue on frame 20. Play your animation and see the color change from red to blue smoothly.
-just in case you don't know how to get to the attribute editor, there are two easy ways to do it. 1) select your object, right-click hold, choose Materials>MaterialAttributes -or- 2) Select your object, then choose Window>Attribute Editor. In the window that comes up, select the material tab (like lambert2, phong1, etc)