How to SELECT a column based on a condition on the column's name?
You can do this without dynamic SQL with some XML trickery.

Create XML of all values for each row and and use local-name() function to extract the value of the column you want.

Here is an example where you perhaps need to change the data types. I assumed integers.

create table dbo.T(Code int, U_Col1 int, U_Col2 int, U_Col3 int)

go

create function dbo.GetT
(
  @Name nvarchar(128),
  @Code int
)
returns table
as
return (
       select T.Code,
              C.X.value('(*[local-name() = sql:variable("@Name")]/text())[1]', 'int') as U_Col
       from dbo.T
         cross apply(select T.* for xml path(''), type) as C(X)
       where T.Code = @Code
       );
go

insert into dbo.T (Code, U_Col1, U_Col2, U_Col3) values
(123, 1, 2, 3),
(456, 4, 5, 6)

go

select * from dbo.GetT('U_Col1', 123);
select * from dbo.GetT('U_Col2', 456);


Note that the names of all columns in the table must be valid as element names in XML.

dbfiddle.uk