Manually update last_updated and last_changed

I know it’s weird to ask this question: is there a way to update the last_updated and last_changed fields of an entity’s state by a script? I know they are the 2 fields in the states database of HA. Can you point me to the right way to do it, probably an API call or SQL update query…?

Even though it could be used for several needs, but here’s my needs now: I have a solar system. I can get the information about the enery upload/download (or consume) to/from the grid, by the REST api from the supplier. However, they only provide the information of yesterday. So if I create an RESTful sensor, the yesterday state will be shown today. That’s why I am thinking of update the last_updated or last_changed properties so it could show correctly in the energy dashboard. If there’s another way, please advice. Thank you.