Found a solution. It seems to be possible to also pass the ID in the target object. The solution was to refer to the id property instead of the name property:
const batchPlay = require("photoshop").action.batchPlay;
const result = batchPlay(
[
{
"_obj": "select",
"_target": [{ "_ref": "layer", "_id": 3}],
"makeVisible": false,
"layerID": [3],
"_isCommand": false,
"_options": {"dialogOptions": "dontDisplay"}
}
],{ "synchronousExecution": false, "modalBehavior": "fail"});