As @AlexandreNeto mentioned, you could create a custom python function in the Field Calculator which creates a range list of values based on the feature count of your active layer. The list is then shuffled and you can extract a unique id value randomly.
You could use something like the following script:
from qgis.core import *
from qgis.gui import *
layer = qgis.utils.iface.activeLayer()
ids = list(range(1, layer.featureCount() + 1))
def random_id(value, feature, parent):
And then use the following as the expression:
Note: You must click the
Save and Load Functions button in the Function Editor before using it on other layers. This is because defining the active layer and creating the list of unique values based on its features count is outside the function in order to avoid re-creating the list each time for each row.