Hey!
In principle a function can accept parameters of any M data types, but a "column" data type doesn't exist.
The closest that you can do is to either pass the names of the columns as text. But in that case you'd also need the context of the table as another parameter. Effectively, you'd need to create a custom function that would do exactly what you have in those steps, which is the easiest form to do it.
I'd suggest not to do it through a custom function and just do it through the UI as you're currently doing it.
A function would be doing exactly those same steps, but just in one step that you won't be able to modify on a per query basis if you ever need to, so there's that dependency.