Replaces the metadata on a value with the new metadata record provided and returns the original value with the new metadata attached.