Posting the comments as an answer to help community.
Its not possible to convert the Azure Function app into Self hosted agent directly, As Azure Function is a serverless resource which scales up and down depending on your trigger's requirement. An alternative is to Dockerize your Function app and run a Self hosted agent in a Docker Function, Reference - Run a self-hosted agent in Docker - Azure Pipelines | Microsoft Learn
Same goes for your Dedicated App service plan used for your Function app resource, I Deployed one Dedicated App Service Function app like below:-
I created one directory to download the agent and run the commands from the section below:-

Now, I visited my Function app > Left pane > Development Tools > Advance Tools > Go > Debug Console > Powershell > powershell terminal will open type below command:-
My Function app with dedicated plan:-


mkdir agent
Output:-

After creating agent directory, I ran below command to download the agent in my App service plan but it failed and its not supported as it raised a warning to raise Azure support, Refer below:-
Command reference1 and reference2
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri 'https://vstsagentpackage.azureedge.net/agent/3.220.2/vsts-agent-win-x64-3.220.2.zip' -UseBasicParsing
Output:- Error
Invoke-WebRequest : Win32 internal error "The handle is invalid" 0x6 occurred
PS C:\home> while reading the console output buffer. Contact Microsoft Customer Support
Services.
At line:1 char:1
+ Invoke-WebRequest -Uri 'https://vstsagentpackage.azureedge.net/agent/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (:) [Invoke-WebRequest], HostExceptio
n
+ FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.PowerShell.Commands.
InvokeWebRequestCommand

I downloaded the Agent in my local machine and directly dragged it in the kudu console and tried running command to install the agent but it failed again as App service console requires Console.Read instead refer below:-

Agent file got transferred to App service plan:-


Agent File got transferred successfully, Now I ran the below commands and it failed:-
Command:-
./config.cmd

Error:-

Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
As we cannot change the default code of installing the Azure Self hosted agent and write Console.Read, This scenario is not possible. Another alternative apart from Dockerizing Function is to host an individual Windows or Linux VM as a self hosted agent and create Function app locally inside it and run it via Azure Devops pipeline.