How do I display a friendly URL link in the frontend?

Modifying the URL structure always consists of two parts: one two modify the URLs you generate with your code, and one to handle the incoming URLs of the new structure. The latter part is done by modifying the rewrite rules.

I have just written a detailed explanation of the relevant rewrite functionality in a response to a similar question, so here is just the code for your situation:

add_action( 'init', 'wpa5444_init' );
function wpa5444_init()
{
    // Remember to flush the rules once manually after you added this code!
    add_rewrite_rule(
        // The regex to match the incoming URL
        'companies/tasks/([^/]+)/?',
        // The resulting internal URL: `index.php` because we still use WordPress
        // `pagename` because we use this WordPress page
        // `category_slug` because we assign the first captured regex part to this variable
        'index.php?pagename=companies&category_slug=$matches[1]',
        // This is a rather specific URL, so we add it to the top of the list
        // Otherwise, the "catch-all" rules at the bottom (for pages and attachments) will "win"
        'top' );
}

add_filter( 'query_vars', 'wpa5444_query_vars' );
function wpa5444_query_vars( $query_vars )
{
    $query_vars[] = 'company_slug';
    return $query_vars;
}

The first part, writing your URLs to match this new pretty structure, is not bundled in one place but spread over all the functions that generate URLs. You will need to write a function to handle your case yourself, since you generate a page URL and add the category part to it. It could look like this:

function wpse5444_company_link( $category_slug = '' )
{
    $company_page_id = 42; // Somehow convert the page slug to page ID
    $link = get_page_link( $company_page_id );
    if ( $category_slug ) {
        // trailingslashit() makes sure $link ends with a "https://wordpress.stackexchange.com/"
        $link = trailingslashit( $link ) . 'tasks/' . $category_slug;
        // user_trailingslashit() adds a final "https://wordpress.stackexchange.com/" if the settings require this,
        // otherwise it is removed
        $link = user_trailingslashit( $link );
    }
    return $link;
}