Suppose $A \subseteq \mathbb{N}$ is such that $\displaystyle{\sum_{n \in A} n^{-1}} = \infty$. Suppose $B \subseteq \mathbb{N}$ is infinite.

Is there a set $X \subseteq [1,\infty)$ and a increasing function $f:[1,\infty) \rightarrow [1,\infty)$ with $\displaystyle{\lim_{x \rightarrow \infty} \dfrac{\ln f(x)}{\ln x}=0}$ such that

$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all } x \in X$$ and $$ \lceil X \rceil \cap B = \{ \lceil x \rceil : x \in X \} \cap B \text{ is infinite}? $$

Here are some observations about the problem.

If $A = B = \mathbb{N}$, we can take $X = \mathbb{N}$ and $f(x)=2$.

Suppose we try $f(x) = (\ln x)^2$. Let's try to figure out which values of $x$ satisfy $|A\cap(x,2x]| \geq \dfrac{x}{f(x)}.$ Seeking a contradiction suppose, $|A\cap(x_k,2x_k]| < \dfrac{x_k}{f(x_k)}$ for all large $x_k=2^k$, $k \in \mathbb{N}$. Then \begin{align} \sum_{n \in A} n^{-1} &\ll \sum_{k=1}^{\infty} \sum_{n \in A\cap(x_k,2x_k] } n^{-1} \ll \sum_{k=1}^{\infty} x_k^{-1} |A\cap(x_k,2x_k]| \\ &\ll \sum_{k=1}^{\infty} f(x_k)^{-1} = (\ln 2)^{-2} \sum_{k=1}^{\infty} k^{-2} < \infty, \end{align} which contradicts $\displaystyle{\sum_{n \in A} n^{-1}} = \infty$. So we have $$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{2^k : k \in \mathbb{N}\}$}$$ Now fix $r \in (1,2]$. Seeking a contradiction suppose, $|A\cap(x_k,2x_k]| < \dfrac{x_k}{f(x_k)}$ for all large $x_k=r^k$, $k \in \mathbb{N}$. Then \begin{align} \sum_{n \in A} n^{-1} &\ll \sum_{k=1}^{\infty} \sum_{n \in A\cap(x_k,2x_k] } n^{-1} \ll \sum_{k=1}^{\infty} x_k^{-1} |A\cap(x_k,2x_k]| \\ &\ll \sum_{k=1}^{\infty} f(x_k)^{-1} = (\ln r)^{-2} \sum_{k=1}^{\infty} k^{-2} < \infty, \end{align} which contradicts $\displaystyle{\sum_{n \in A} n^{-1}} = \infty$. So we have $$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{r^k : k \in \mathbb{N}\}$}$$ Considering all values of $r$ together, we have that there is a set $X$ which contains an infinite subset of $\{r^k : k \in \mathbb{N}\}$ for all $r \in (1,2]$ and for which $$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x \in X$}.$$ If we fix $r \in (1,2]$ again. We can run the argument above with $x_k$ any sequence with $r^k \leq x_k \leq 2^k$ for all large $k$. This makes our set $X$ even bigger. The question is whether $\lceil X \rceil \cap B$ is infinite.

Suppose we try the different function $f(x) = \exp(\sqrt{\ln x})$. Let's try to figure out which values of $x$ satisfy $|A\cap(x,2x]| \geq \dfrac{x}{f(x)}.$ Seeking a contradiction suppose, $|A\cap(x_k,2x_k]| < \dfrac{x_k}{f(x_k)}$ for all large $x_k=\exp((2\ln k)^2)$, $k \in \mathbb{N}$. Then \begin{align} \sum_{n \in A} n^{-1} &\ll \sum_{k=1}^{\infty} \sum_{n \in A\cap(x_k,2x_k] } n^{-1} \ll \sum_{k=1}^{\infty} x_k^{-1} |A\cap(x_k,2x_k]| \\ &\ll \sum_{k=1}^{\infty} f(x_k)^{-1} = \sum_{k=1}^{\infty} k^{-2} < \infty, \end{align} which contradicts $\displaystyle{\sum_{n \in A} n^{-1}} = \infty$. So we have $$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{\exp((2\ln k)^2) : k \in \mathbb{N}\}$}$$ We can run the argument with $x_k$ being any sequence with $\exp((2\ln k)^2) \leq x_k \leq 2^k$ for all large $k$. So we can run it with $x_k = r^k$ for any $r \in (1,2]$, for example. We get that $$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x \in X$}$$ where $X$ is an even bigger set than in the previous example. However, it's still not clear that $\lceil X \rceil \cap B$ is infinite.