Of course it is legal, there are many reasons for changing the cost index.
- need to conserve fuel so may set it to '0'
- need to save time at the cost of fuel so set it above flight plan level.
Only thing you need to keep in mind is you may need to update ATC of your new planned speed if you are not in a radar environment and it effects your estimated times.