Updating user's picture doesn't work

function (user, context, callback) {
  var url = require('url');
  
  user.picture = url.format('avatar_url_here');

  callback(null, user, context);
}

The above rule doesn’t update the picture property.

I tried this as well w/o any luck.

function (user, context, callback) {
  var url = require('url');
  
  var u = url.parse(user.picture, true);
  u.query.d = 'http://url_to_avatar';
  user.picture = url.format(u);

  callback(null, user, context);
}

Has the functionality been deprecated? Is this even possible to do? The documentation states that it is.

As mentioned in the documentation you linked:

At this stage this attribute is not directly editable, however you can use the user_metadata picture attribute in your front-end as desired. (…)

(emphasis is mine)

In addition, the sample rule below that you also tried is meant to override the user picture as part of the authentication transaction being executed. It will not persist the change, but for the transaction for which the rule runs it effectively overrides the value of the user picture in certain conditions.

For example, if you requested the OpenID Connect profile scope a quick test shows that the value returned in the picture claim within the issued ID token would be overridden by the rule and contain the value you would set.

In conclusion, at this time, you cannot edit and persist the picture value at the root of the user, however, you may override it’s value as part of an authentication transaction or opt to just use a custom value within the user metadata within your own client applications.