I need to replace this number's 1234567891011 first and last four digits with stars.
How should I do it with replace function?
Use substring function instead of replace and concatenate stars with "middle" part of your string:
declare @str nvarchar(max)
select @str = '1234567891011'
select '****' + substring(@str, 5, len(@str) - 8) + '****'
Output:
****56789****