How can I get variable from php function and use it in wp_localize_script?

Instead of passing count through wp_localize_script you should just handle the JS logic in JS. For example in JS:

var count = document.querySelectorAll( 'input[name^="link"]' ).length;

That would get the count of all input elements where the name attribute starts with link.

It would be more performant to scope the selector by adding a class to the span that is unique to your plugin or theme:

In your PHP:

                        printf('<span class="theme-name-term-input">
                            <input type="text" name="link[%1$s] value="%2$s" />
                            <input class="button remove" type="button" value="%3$s" />
                        </span>', 
                        $count, $link, __('Remove Link') );

Then the JS:

var count = document.querySelectorAll( '.theme-name-term-input' ).length;

This would also help protect against other plugins (or themes) which might add fields with similar naming constructs providing incorrect counts.

In most circumstances you need to update count as well in JS as things are added/removed. By doing the same query, you will get the updated count, or you can increment/decrement based on an action (like click).