If you want to create a
controller rendering then there is an option to
clone an existing component in
Sitecore SXA. Follow this article to know how to clone a component in SXA.
And to know more about creating a
controller rendering in SXA, you need to follow this article shared by
Also if you want to check the code of an existing OOTB Sitecore controller then you need to go to a particular component and you will find the controller class and assembly in the controller field like this.
In this example the controller is
Sitecore.XA.Feature.Composites.Controllers.AccordionController and you can find this in the
Sitecore.XA.Feature.Composites DLL. So you need to use some third-party tools to extract this DLL and you will be able to find the code.
Then if you want to extend this code, you can copy the same logic in your controller class and extend it as per your needs.
Then in the above image in the Controller field, you need to pass your class and assembly name and then this will work with your logic.
Hope this is enough information for you to start.