Depending on the phone, Usually you would do this in the phones dial plan. I have done this with yealink phones.

You could hotline the extensions, but they would then loose the ability to dial internal extensions.