Player:SetNoTarget sets a player's ability to be targeted by bots. I wrote up a script real fast with comments so that you can see how to do it for yourself

function ulx.notarg( calling_ply, target_ply, should_notarg ) -- Initializes the function, everything executed is after here and before the 'end'.
target_ply:SetNoTarget( not should_notarg ) -- Uses Player:SetNoTarget() to set a player's targetability.
ulx.fancyLogAdmin( calling_ply, "#A set #T's targetability to #s", target_ply, tostring( should_notarg ) ) -- Logs the command in the chat so everyone knows what happened.
end -- Ends the function. Nothing after this will be executed in the command below.
local notarg = ulx.command( "Utility", "ulx notarg", ulx.notarg, "!notarget" ) -- Registers the command under the "Utility" tab, makes the console command to "ulx notarg", makes the command execute the 'ulx.notarg' function, and makes the chat command "!notarget".
notarg:addParam{ type=ULib.cmds.PlayerArg } -- Allows to target another player. This param is added to the 'target_ply' variable above.
notarg:addParam{ type=ULib.cmds.BoolArg, invisible=true } -- Allows for an opposite command. This param is added to the 'should_notarg' variable above.
notarg:defaultAccess( ULib.ACCESS_ADMIN ) -- Sets the default access for the command to 'admin' or higher.
notarg:setOpposite( "ulx allowtarget", { _, _, false }, "!allowtarget" ) -- Adds an opposite command to allow resetting targetability.
notarg:help( "Makes a target either targetable or not targetable by bots." ) -- The message that shows up under 'ulx help'
Keep in mind I wrote this up really quickly, can't guarantee if this will work or not, but that is how the
Player:SetNoTarget works, and future reference for how to write up your own ULX commands
