Override list.phtml [For catalog category view] file at
app/design/frontend/<themename>
/default/Magento_Catalog/templates/product/list.phtml
and apply this customization at line no 78
<?php if ($_product->isSaleable()): ?>
<?php if ($_product->getPrice() > 0): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_product->getSku()) ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post">
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>">
<input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
class="action tocart primary">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
</form>
<?php else: ?>
<div class="action tocart primary"><span><?= /* @escapeNotVerified */ __('Coming Soon') ?></span></div>
<?php endif; ?>
<?php else: ?>
<?php if ($_product->isAvailable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
override the addtocart.phtml [For catalog product view] file at below path and add this code :
app/design/frontend/<themename>
/default/Magento_Catalog/templates/product/product/view/addtocart.phtml
<?php if ($_product->getPrice() > 0) : ?>
<div class="actions">
<button type="submit"
title="<?= /* @escapeNotVerified */ $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?= /* @escapeNotVerified */ $buttonTitle ?></span>
</button>
<?= $block->getChildHtml('', true) ?>
</div>
<?php else: ?>
<button type="button"
title="<?= $block->escapeHtml(__('Coming Soon')) ?>"
class="action tocart primary">
<span><?= /* @escapeNotVerified */ __('Coming Soon') ?></span>
</button>
<?php endif; ?>